<?
/*# Версия ПО (ДМ) 1.0.0.0 ( (c)2018 MISOFT Продукт защищен регистрацией патента и авторских прав! www.misoft.studio )
####################################################################################################################*/
  
  define( 'ROOT_DIR', $_SERVER['DOCUMENT_ROOT'] );
  include_once ROOT_DIR . '/engine/config.php';
  include_once ROOT_DIR . '/engine/function.php';

  function visit_statistic( $user, $width, $height ) {
	
	#Достаем количество сделаной работы за все время
	$earing_all_time = mysql_fetch_array( mysql_query( "SELECT * FROM user WHERE id = '" . ( int ) $user . "'" ) );
    
    #Считаем по днях количество кликов в серфинге
	$serf1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$serf2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$serf3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$serf4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$serf5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$serf6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$serf7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $serf1['sum'] ) ) $serf1['sum'] = 0;
	if ( empty( $serf2['sum'] ) ) $serf2['sum'] = 0;
	if ( empty( $serf3['sum'] ) ) $serf3['sum'] = 0;
	if ( empty( $serf4['sum'] ) ) $serf4['sum'] = 0;
	if ( empty( $serf5['sum'] ) ) $serf5['sum'] = 0;
	if ( empty( $serf6['sum'] ) ) $serf6['sum'] = 0;
	if ( empty( $serf7['sum'] ) ) $serf7['sum'] = 0;
	
    #Считаем по днях количество кликов в автосерфинге
	$autoserf1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$autoserf2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$autoserf3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$autoserf4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$autoserf5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$autoserf6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$autoserf7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $autoserf1['sum'] ) ) $autoserf1['sum'] = 0;
	if ( empty( $autoserf2['sum'] ) ) $autoserf2['sum'] = 0;
	if ( empty( $autoserf3['sum'] ) ) $autoserf3['sum'] = 0;
	if ( empty( $autoserf4['sum'] ) ) $autoserf4['sum'] = 0;
	if ( empty( $autoserf5['sum'] ) ) $autoserf5['sum'] = 0;
	if ( empty( $autoserf6['sum'] ) ) $autoserf6['sum'] = 0;
	if ( empty( $autoserf7['sum'] ) ) $autoserf7['sum'] = 0;
	
    #Считаем по днях количество пройденных тестов
	$test1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$test2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$test3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$test4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$test5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$test6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$test7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $test1['sum'] ) ) $test1['sum'] = 0;
	if ( empty( $test2['sum'] ) ) $test2['sum'] = 0;
	if ( empty( $test3['sum'] ) ) $test3['sum'] = 0;
	if ( empty( $test4['sum'] ) ) $test4['sum'] = 0;
	if ( empty( $test5['sum'] ) ) $test5['sum'] = 0;
	if ( empty( $test6['sum'] ) ) $test6['sum'] = 0;
	if ( empty( $test7['sum'] ) ) $test7['sum'] = 0;
	
    #Считаем по днях количество выполненых заданий
	$task1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$task2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$task3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$task4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$task5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$task6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$task7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $task1['sum'] ) ) $task1['sum'] = 0;
	if ( empty( $task2['sum'] ) ) $task2['sum'] = 0;
	if ( empty( $task3['sum'] ) ) $task3['sum'] = 0;
	if ( empty( $task4['sum'] ) ) $task4['sum'] = 0;
	if ( empty( $task5['sum'] ) ) $task5['sum'] = 0;
	if ( empty( $task6['sum'] ) ) $task6['sum'] = 0;
	if ( empty( $task7['sum'] ) ) $task7['sum'] = 0;
	
    #Считаем по днях количество выполненых заданий вконтакте
	$vkontakte1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$vkontakte2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$vkontakte3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$vkontakte4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$vkontakte5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$vkontakte6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$vkontakte7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $vkontakte1['sum'] ) ) $vkontakte1['sum'] = 0;
	if ( empty( $vkontakte2['sum'] ) ) $vkontakte2['sum'] = 0;
	if ( empty( $vkontakte3['sum'] ) ) $vkontakte3['sum'] = 0;
	if ( empty( $vkontakte4['sum'] ) ) $vkontakte4['sum'] = 0;
	if ( empty( $vkontakte5['sum'] ) ) $vkontakte5['sum'] = 0;
	if ( empty( $vkontakte6['sum'] ) ) $vkontakte6['sum'] = 0;
	if ( empty( $vkontakte7['sum'] ) ) $vkontakte7['sum'] = 0;
	
    #Считаем по днях количество просмотренных видео Youtube
	$youtube1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$youtube2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$youtube3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$youtube4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$youtube5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$youtube6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$youtube7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $youtube1['sum'] ) ) $youtube1['sum'] = 0;
	if ( empty( $youtube2['sum'] ) ) $youtube2['sum'] = 0;
	if ( empty( $youtube3['sum'] ) ) $youtube3['sum'] = 0;
	if ( empty( $youtube4['sum'] ) ) $youtube4['sum'] = 0;
	if ( empty( $youtube5['sum'] ) ) $youtube5['sum'] = 0;
	if ( empty( $youtube6['sum'] ) ) $youtube6['sum'] = 0;
	if ( empty( $youtube7['sum'] ) ) $youtube7['sum'] = 0;
	
	$month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
    
    switch ( date( 'd' ) ) {
	  case 1:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  case 2:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  case 3:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  case 4:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  case 5:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  case 6:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  default:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
    }
    ?>
	  <script type="text/javascript">
		$(document).ready(function() {
			
		  Highcharts.chart('container', {
			
			chart: {
			  type: 'areaspline',
			  backgroundColor: '#fff'
			},
			
			exporting: {
			  buttons: {
				contextButton: {
				  enabled: false
				}
			  }
			},
			  
			title: {
			  text: ''
			},
			legend: {
			  enabled: false,
			  layout: 'horizontal',
			  align: 'left',
			  verticalAlign: 'top',
			  x: 50,
			  y: 50,
			  floating: true,
			  borderWidth: 1,
			  backgroundColor: '#FFFFFF'
			},
			xAxis: {
			  categories: [
				'<?=( int ) date( 'd', time() - 86400 * 6 ) . $thismonth7?>',
				'<?=( int ) date( 'd', time() - 86400 * 5 ) . $thismonth6?>',
				'<?=( int ) date( 'd', time() - 86400 * 4 ) . $thismonth5?>',
				'<?=( int ) date( 'd', time() - 86400 * 3 ) . $thismonth4?>',
				'<?=( int ) date( 'd', time() - 86400 * 2 ) . $thismonth3?>',
				'<?=( int ) date( 'd', time() - 86400 ) . $thismonth2?>',
				'<?=( int ) date( 'd', time() ) . $thismonth1?>'
			  ]
				
			},
			yAxis: {
			  title: {
				enabled: false
			  }
			},
			
			credits: {
			  enabled: false
			},
			plotOptions: {
			  areaspline: {
				fillOpacity: 0.5
			  }
			},
			series: [{
			  name: 'Серфинг',
			  data: [ <?=$serf7['sum']?>, <?=$serf6['sum']?>, <?=$serf5['sum']?>, <?=$serf4['sum']?>, <?=$serf3['sum']?>, <?=$serf2['sum']?>, <?=$serf1['sum']?> ],
			  color: '#1D4867' 
			}, {
			  name: 'Автосерфинг',
			  data: [ <?=$autoserf7['sum']?>, <?=$autoserf6['sum']?>, <?=$autoserf5['sum']?>, <?=$autoserf4['sum']?>, <?=$autoserf3['sum']?>, <?=$autoserf2['sum']?>, <?=$autoserf1['sum']?> ],
			  color: '#3DC49B' 
			}, {
			  name: 'Тесты',
			  data: [ <?=$test7['sum']?>, <?=$test6['sum']?>, <?=$test5['sum']?>, <?=$test4['sum']?>, <?=$test3['sum']?>, <?=$test2['sum']?>, <?=$test1['sum']?> ],
			  color: '#333333'
			}, {
			  name: 'Задания',
			  data: [ <?=$task7['sum']?>, <?=$task6['sum']?>, <?=$task5['sum']?>, <?=$task4['sum']?>, <?=$task3['sum']?>, <?=$task2['sum']?>, <?=$task1['sum']?> ],
			  color: '#1D8BAE'
			},{
			  name: 'Вконтакте',
			  data: [ <?=$vkontakte7['sum']?>, <?=$vkontakte6['sum']?>, <?=$vkontakte5['sum']?>, <?=$vkontakte4['sum']?>, <?=$vkontakte3['sum']?>, <?=$vkontakte2['sum']?>, <?=$vkontakte1['sum']?> ],
			  color: '#5581B5'
			}, {
			  name: 'Youtube',
			  data: [ <?=$youtube7['sum']?>, <?=$youtube6['sum']?>, <?=$youtube5['sum']?>, <?=$youtube4['sum']?>, <?=$youtube3['sum']?>, <?=$youtube2['sum']?>, <?=$youtube1['sum']?> ],
			  color: '#CA5B5D'
			}]
			
		  });
			
		  $('#earnings_summ1').tipTip({defaultPosition:'right'});
		  $('#earnings_summ2').tipTip({defaultPosition:'right'});
		  $('#earnings_summ3').tipTip({defaultPosition:'right'});
		  $('#earnings_summ4').tipTip({defaultPosition:'right'});
		  $('#earnings_summ5').tipTip({defaultPosition:'right'});
		  $('#earnings_summ6').tipTip({defaultPosition:'right'});
		});
	  </script>
	  <div id="container" style="width: <?= ( int ) $width?>px; height: <?= ( int ) $height?>px; margin-left: 35px;"></div>
	  <div class="wrap_body_stat">
		<div style="color: #1D4867; cursor: help; " id="earnings_summ1" title="Количество просмотренных сайтов в серфинге за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #1D4867; font-size: 12px;"></span>Серфинг&nbsp;&nbsp;
		  <span style="background: #1D4867; color: #fff;"><?=$earing_all_time['serf_view'] ?></span>
		</div>
		<div style="color: #3DC49B; cursor: help; " id="earnings_summ2" title="Количество просмотренных сайтов в авто-серфинге за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #3DC49B; font-size: 12px;"></span>Авто-серфинг&nbsp;&nbsp;
		  <span style="background: #3DC49B; color: #fff;"><?=$earing_all_time['autoserf_view'] ?></span>
		</div>
		<div style="color: #333333; cursor: help; " id="earnings_summ3" title="Количество пройденных тестов за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #333333; font-size: 12px;"></span>Тесты&nbsp;&nbsp;
		  <span style="background: #333333; color: #fff;"><?=$earing_all_time['test_view'] ?></span>
		</div>
		<div style="color: #1D8BAE; cursor: help; " id="earnings_summ4" title="Количество выполненных заданий за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #1D8BAE; font-size: 12px;"></span>Задания&nbsp;&nbsp;
		  <span style="background: #1D8BAE; color: #fff;"><?=$earing_all_time['tasks_view'] ?></span>
		</div>
		<div style="color: #5581B5; cursor: help; " id="earnings_summ5" title="Количество лайков, подписок, репостов за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #5581B5; font-size: 12px;"></span>Вконтакте&nbsp;&nbsp;
		  <span style="background: #5581B5; color: #fff;"><?=$earing_all_time['vk_view'] ?></span>
		</div>
		<div style="color: #CA5B5D; cursor: help; " id="earnings_summ6" title="Количество просмотров видео за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #CA5B5D; font-size: 12px;"></span>Youtube&nbsp;&nbsp;
		  <span style="background: #CA5B5D; color: #fff;"><?=$earing_all_time['youtube_view'] ?></span>
		</div>
	  </div>
    <? 
  }

  function visit_statistic_wall( $user, $width, $height ) {
    
	#Достаем количество сделаной работы за все время
	$earing_all_time = mysql_fetch_array( mysql_query( "SELECT * FROM user WHERE id = '" . ( int ) $user . "'" ) );
	
    #Считаем по днях количество кликов в серфинге
	$serf1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$serf2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$serf3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$serf4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$serf5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$serf6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$serf7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '1' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $serf1['sum'] ) ) $serf1['sum'] = 0;
	if ( empty( $serf2['sum'] ) ) $serf2['sum'] = 0;
	if ( empty( $serf3['sum'] ) ) $serf3['sum'] = 0;
	if ( empty( $serf4['sum'] ) ) $serf4['sum'] = 0;
	if ( empty( $serf5['sum'] ) ) $serf5['sum'] = 0;
	if ( empty( $serf6['sum'] ) ) $serf6['sum'] = 0;
	if ( empty( $serf7['sum'] ) ) $serf7['sum'] = 0;
	
    #Считаем по днях количество кликов в автосерфинге
	$autoserf1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$autoserf2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$autoserf3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$autoserf4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$autoserf5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$autoserf6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$autoserf7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '2' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $autoserf1['sum'] ) ) $autoserf1['sum'] = 0;
	if ( empty( $autoserf2['sum'] ) ) $autoserf2['sum'] = 0;
	if ( empty( $autoserf3['sum'] ) ) $autoserf3['sum'] = 0;
	if ( empty( $autoserf4['sum'] ) ) $autoserf4['sum'] = 0;
	if ( empty( $autoserf5['sum'] ) ) $autoserf5['sum'] = 0;
	if ( empty( $autoserf6['sum'] ) ) $autoserf6['sum'] = 0;
	if ( empty( $autoserf7['sum'] ) ) $autoserf7['sum'] = 0;
	
    #Считаем по днях количество пройденных тестов
	$test1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$test2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$test3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$test4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$test5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$test6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$test7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '3' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $test1['sum'] ) ) $test1['sum'] = 0;
	if ( empty( $test2['sum'] ) ) $test2['sum'] = 0;
	if ( empty( $test3['sum'] ) ) $test3['sum'] = 0;
	if ( empty( $test4['sum'] ) ) $test4['sum'] = 0;
	if ( empty( $test5['sum'] ) ) $test5['sum'] = 0;
	if ( empty( $test6['sum'] ) ) $test6['sum'] = 0;
	if ( empty( $test7['sum'] ) ) $test7['sum'] = 0;
	
    #Считаем по днях количество выполненых заданий
	$task1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$task2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$task3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$task4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$task5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$task6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$task7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '4' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $task1['sum'] ) ) $task1['sum'] = 0;
	if ( empty( $task2['sum'] ) ) $task2['sum'] = 0;
	if ( empty( $task3['sum'] ) ) $task3['sum'] = 0;
	if ( empty( $task4['sum'] ) ) $task4['sum'] = 0;
	if ( empty( $task5['sum'] ) ) $task5['sum'] = 0;
	if ( empty( $task6['sum'] ) ) $task6['sum'] = 0;
	if ( empty( $task7['sum'] ) ) $task7['sum'] = 0;
	
    #Считаем по днях количество выполненых заданий вконтакте
	$vkontakte1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$vkontakte2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$vkontakte3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$vkontakte4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$vkontakte5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$vkontakte6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$vkontakte7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '5' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $vkontakte1['sum'] ) ) $vkontakte1['sum'] = 0;
	if ( empty( $vkontakte2['sum'] ) ) $vkontakte2['sum'] = 0;
	if ( empty( $vkontakte3['sum'] ) ) $vkontakte3['sum'] = 0;
	if ( empty( $vkontakte4['sum'] ) ) $vkontakte4['sum'] = 0;
	if ( empty( $vkontakte5['sum'] ) ) $vkontakte5['sum'] = 0;
	if ( empty( $vkontakte6['sum'] ) ) $vkontakte6['sum'] = 0;
	if ( empty( $vkontakte7['sum'] ) ) $vkontakte7['sum'] = 0;
	
    #Считаем по днях количество просмотренных видео Youtube
	$youtube1 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$youtube2 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) ) . "'" ) );
	$youtube3 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 ) . "'" ) );
	$youtube4 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 2 ) . "'" ) );
	$youtube5 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 3 ) . "'" ) );
	$youtube6 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 4 ) . "'" ) );
	$youtube7 = mysql_fetch_array( mysql_query( "SELECT SUM(summ) as sum FROM earnings_statistics WHERE type = '6' AND iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 86400 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 86400 * 5 ) . "'" ) );

	if ( empty( $youtube1['sum'] ) ) $youtube1['sum'] = 0;
	if ( empty( $youtube2['sum'] ) ) $youtube2['sum'] = 0;
	if ( empty( $youtube3['sum'] ) ) $youtube3['sum'] = 0;
	if ( empty( $youtube4['sum'] ) ) $youtube4['sum'] = 0;
	if ( empty( $youtube5['sum'] ) ) $youtube5['sum'] = 0;
	if ( empty( $youtube6['sum'] ) ) $youtube6['sum'] = 0;
	if ( empty( $youtube7['sum'] ) ) $youtube7['sum'] = 0;

	$month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
    
    switch ( date( 'd' ) ) {
	  case 1:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  case 2:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  case 3:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  case 4:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  case 5:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  case 6:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 2] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
	  default:
		$thismonth7 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth6 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth5 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth4 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth3 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth2 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		$thismonth1 = ' ' . $month[( int ) date( 'm', time() ) - 1] . ' ' . date( 'Y', time() );
		break;
    }
    ?>
	  <script type="text/javascript">
		$(document).ready(function() {
			
		  Highcharts.chart('container', {
			chart: {
			  type: 'areaspline',
			  backgroundColor: '#fff'
			},
			
			exporting: {
			  buttons: {
				contextButton: {
				  enabled: false
				}
			  }
			},
			  
			title: {
			  text: ''
			},
			legend: {
			  enabled: false,
			  layout: 'horizontal',
			  align: 'left',
			  verticalAlign: 'top',
			  x: 50,
			  y: 50,
			  floating: true,
			  borderWidth: 1,
			  backgroundColor: '#FFFFFF'
			},
			xAxis: {
			  categories: [
				'<?=( int ) date( 'd', time() - 86400 * 6 ) . $thismonth7?>',
				'<?=( int ) date( 'd', time() - 86400 * 5 ) . $thismonth6?>',
				'<?=( int ) date( 'd', time() - 86400 * 4 ) . $thismonth5?>',
				'<?=( int ) date( 'd', time() - 86400 * 3 ) . $thismonth4?>',
				'<?=( int ) date( 'd', time() - 86400 * 2 ) . $thismonth3?>',
				'<?=( int ) date( 'd', time() - 86400 ) . $thismonth2?>',
				'<?=( int ) date( 'd', time() ) . $thismonth1?>'
			  ]
				
			},
			yAxis: {
			  title: {
				enabled: false
			  }
			},
			
			credits: {
			  enabled: false
			},
			plotOptions: {
			  areaspline: {
				fillOpacity: 0.5
			  }
			},
			series: [{
			  name: 'Серфинг',
			  data: [ <?=$serf7['sum']?>, <?=$serf6['sum']?>, <?=$serf5['sum']?>, <?=$serf4['sum']?>, <?=$serf3['sum']?>, <?=$serf2['sum']?>, <?=$serf1['sum']?> ],
			  color: '#1D4867' 
			}, {
			  name: 'Автосерфинг',
			  data: [ <?=$autoserf7['sum']?>, <?=$autoserf6['sum']?>, <?=$autoserf5['sum']?>, <?=$autoserf4['sum']?>, <?=$autoserf3['sum']?>, <?=$autoserf2['sum']?>, <?=$autoserf1['sum']?> ],
			  color: '#3DC49B' 
			}, {
			  name: 'Тесты',
			  data: [ <?=$test7['sum']?>, <?=$test6['sum']?>, <?=$test5['sum']?>, <?=$test4['sum']?>, <?=$test3['sum']?>, <?=$test2['sum']?>, <?=$test1['sum']?> ],
			  color: '#333333'
			}, {
			  name: 'Задания',
			  data: [ <?=$task7['sum']?>, <?=$task6['sum']?>, <?=$task5['sum']?>, <?=$task4['sum']?>, <?=$task3['sum']?>, <?=$task2['sum']?>, <?=$task1['sum']?> ],
			  color: '#1D8BAE'
			},{
			  name: 'Вконтакте',
			  data: [ <?=$vkontakte7['sum']?>, <?=$vkontakte6['sum']?>, <?=$vkontakte5['sum']?>, <?=$vkontakte4['sum']?>, <?=$vkontakte3['sum']?>, <?=$vkontakte2['sum']?>, <?=$vkontakte1['sum']?> ],
			  color: '#5581B5'
			}, {
			  name: 'Youtube',
			  data: [ <?=$youtube7['sum']?>, <?=$youtube6['sum']?>, <?=$youtube5['sum']?>, <?=$youtube4['sum']?>, <?=$youtube3['sum']?>, <?=$youtube2['sum']?>, <?=$youtube1['sum']?> ],
			  color: '#CA5B5D'
			}]
		  });

		  $('#earnings_summ1').tipTip({defaultPosition:'right'});
		  $('#earnings_summ2').tipTip({defaultPosition:'right'});
		  $('#earnings_summ3').tipTip({defaultPosition:'right'});
		  $('#earnings_summ4').tipTip({defaultPosition:'right'});
		  $('#earnings_summ5').tipTip({defaultPosition:'right'});
		  $('#earnings_summ6').tipTip({defaultPosition:'right'});
		});
	  </script>
	  <div style="margin: 10px 0 0 25px;">
	  <div id="container" style="width: <?= ( int ) $width?>px; height: <?= ( int ) $height?>px; margin-bottom: 10px;" class="div_centralizator"></div>
	  <div class="wrap_body_stat">
		<div style="color: #1D4867; cursor: help; " id="earnings_summ1" title="Количество просмотренных сайтов в серфинге за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #1D4867; font-size: 12px;"></span>Серфинг&nbsp;&nbsp;
		  <span style="background: #1D4867; color: #fff;"><?=$earing_all_time['serf_view'] ?></span>
		</div>
		<div style="color: #3DC49B; cursor: help; " id="earnings_summ2" title="Количество просмотренных сайтов в авто-серфинге за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #3DC49B; font-size: 12px;"></span>Авто-серфинг&nbsp;&nbsp;
		  <span style="background: #3DC49B; color: #fff;"><?=$earing_all_time['autoserf_view'] ?></span>
		</div>
		<div style="color: #333333; cursor: help; " id="earnings_summ3" title="Количество пройденных тестов за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #333333; font-size: 12px;"></span>Тесты&nbsp;&nbsp;
		  <span style="background: #333333; color: #fff;"><?=$earing_all_time['test_view'] ?></span>
		</div>
		<div style="color: #1D8BAE; cursor: help; " id="earnings_summ4" title="Количество выполненных заданий за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #1D8BAE; font-size: 12px;"></span>Задания&nbsp;&nbsp;
		  <span style="background: #1D8BAE; color: #fff;"><?=$earing_all_time['tasks_view'] ?></span>
		</div>
		<div style="color: #5581B5; cursor: help; " id="earnings_summ5" title="Количество лайков, подписок, репостов за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #5581B5; font-size: 12px;"></span>Вконтакте&nbsp;&nbsp;
		  <span style="background: #5581B5; color: #fff;"><?=$earing_all_time['vk_view'] ?></span>
		</div>
		<div style="color: #CA5B5D; cursor: help; " id="earnings_summ6" title="Количество просмотров видео за все время.">
		  <span class="glyphicon glyphicon-asterisk" style="color: #CA5B5D; font-size: 12px;"></span>Youtube&nbsp;&nbsp;
		  <span style="background: #CA5B5D; color: #fff;"><?=$earing_all_time['youtube_view'] ?></span>
		</div>
	  </div>
	  </div>
	<? 
  } 

  function money_statistic( $user, $width, $height ) {
    
    $month = array( '', 'январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь' );
    $time = time();
	
	#Вытягиваем сумму выплат по месяцам (последние 7м.)
	$pay_history1 = mysql_fetch_array( mysql_query( "SELECT SUM(money) as sum FROM pay_history WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 1 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400) . "'" ) );
	$pay_history2 = mysql_fetch_array( mysql_query( "SELECT SUM(money) as sum FROM pay_history WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 ) . "'" ) );
	$pay_history3 = mysql_fetch_array( mysql_query( "SELECT SUM(money) as sum FROM pay_history WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 * 2 ) . "'" ) );
	$pay_history4 = mysql_fetch_array( mysql_query( "SELECT SUM(money) as sum FROM pay_history WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 * 3 ) . "'" ) );
	$pay_history5 = mysql_fetch_array( mysql_query( "SELECT SUM(money) as sum FROM pay_history WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 * 4 ) . "'" ) );
	$pay_history6 = mysql_fetch_array( mysql_query( "SELECT SUM(money) as sum FROM pay_history WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 * 7 ) . "'" ) );
	$pay_history7 = mysql_fetch_array( mysql_query( "SELECT SUM(money) as sum FROM pay_history WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 7 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 * 6 ) . "'" ) );
	
	if ( empty( $pay_history1['sum'] ) ) $pay_history1['sum'] = 0;
	if ( empty( $pay_history2['sum'] ) ) $pay_history2['sum'] = 0;
	if ( empty( $pay_history3['sum'] ) ) $pay_history3['sum'] = 0;
	if ( empty( $pay_history4['sum'] ) ) $pay_history4['sum'] = 0;
	if ( empty( $pay_history5['sum'] ) ) $pay_history5['sum'] = 0;
	if ( empty( $pay_history6['sum'] ) ) $pay_history6['sum'] = 0;
	if ( empty( $pay_history7['sum'] ) ) $pay_history7['sum'] = 0;
	
	#Вытягиваем сумму пополнений по месяцам (последние 7м.)
	$history_reklama_pay1 = mysql_fetch_array( mysql_query( "SELECT SUM(price) as sum FROM history_reklama_pay WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 1 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) + 86400 ) . "'" ) );
	$history_reklama_pay2 = mysql_fetch_array( mysql_query( "SELECT SUM(price) as sum FROM history_reklama_pay WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 2 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 ) . "'" ) );
	$history_reklama_pay3 = mysql_fetch_array( mysql_query( "SELECT SUM(price) as sum FROM history_reklama_pay WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 3 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 * 2 ) . "'" ) );
	$history_reklama_pay4 = mysql_fetch_array( mysql_query( "SELECT SUM(price) as sum FROM history_reklama_pay WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 4 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 * 3 ) . "'" ) );
	$history_reklama_pay5 = mysql_fetch_array( mysql_query( "SELECT SUM(price) as sum FROM history_reklama_pay WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 5 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 * 4 ) . "'" ) );
	$history_reklama_pay6 = mysql_fetch_array( mysql_query( "SELECT SUM(price) as sum FROM history_reklama_pay WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 6 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 * 7 ) . "'" ) );
	$history_reklama_pay7 = mysql_fetch_array( mysql_query( "SELECT SUM(price) as sum FROM history_reklama_pay WHERE iduser = '" . ( int ) $user . "' AND date >= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:01' ) - 2629743 * 7 ) . "' and date <= '" . ( strtotime( date('Y').'-'.date('m').'-'.date('d').' 00:00' ) - 2629743 * 6 ) . "'" ) );
	
	if ( empty( $history_reklama_pay1['sum'] ) ) $history_reklama_pay1['sum'] = 0;
	if ( empty( $history_reklama_pay2['sum'] ) ) $history_reklama_pay2['sum'] = 0;
	if ( empty( $history_reklama_pay3['sum'] ) ) $history_reklama_pay3['sum'] = 0;
	if ( empty( $history_reklama_pay4['sum'] ) ) $history_reklama_pay4['sum'] = 0;
	if ( empty( $history_reklama_pay5['sum'] ) ) $history_reklama_pay5['sum'] = 0;
	if ( empty( $history_reklama_pay6['sum'] ) ) $history_reklama_pay6['sum'] = 0;
	if ( empty( $history_reklama_pay7['sum'] ) ) $history_reklama_pay7['sum'] = 0;
	
    ?>
	  <script type="text/javascript">
	    $(document).ready(function() {
		
		  Highcharts.chart('moneycnt', {
		    chart: {
			  type: 'column',
			  backgroundColor: '#fff'
		    },
		
		    exporting: {
			  buttons: {
			    contextButton: {
				  enabled: false
			    }
			  }
		    },
		  
		    title: {
			  text: ''
		    },
		    legend: {
			  enabled: false,
			  layout: 'horizontal',
			  align: 'left',
			  verticalAlign: 'top',
			  x: 50,
			  y: 50,
			  floating: true,
			  borderWidth: 1,
			  backgroundColor: '#FFFFFF'
		    },
		    xAxis: {
			  categories: [
			    '<?=$month[ ( int ) date( 'n', $time - 2629743 * 6 ) ]?> <?=date( 'Y', $time - 2629743 * 6)?>',
			    '<?=$month[ ( int ) date( 'n', $time - 2629743 * 5 ) ]?> <?=date( 'Y', $time - 2629743 * 5 )?>',
			    '<?=$month[ ( int ) date( 'n', $time - 2629743 * 4 ) ]?> <?=date( 'Y', $time - 2629743 * 4 )?>',
			    '<?=$month[ ( int ) date( 'n', $time - 2629743 * 3 ) ]?> <?=date( 'Y', $time - 2629743 * 3 )?>',
			    '<?=$month[ ( int ) date( 'n', $time - 2629743 * 2 ) ]?> <?=date( 'Y', $time - 2629743 * 2 )?>',
			    '<?=$month[ ( int ) date( 'n', $time - 2629743 * 1 ) ]?> <?=date( 'Y', $time - 2629743 * 1 )?>',
			    '<?=$month[ ( int ) date( 'n', $time ) ]?> <?=date( 'Y', $time )?>'
			  ]
			},
		    yAxis: {
			  title: {
			    enabled: false
			  }
		    },
		
		    credits: {
			  enabled: false
		    },
		    tooltip: {
			  headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
			  pointFormat: '<tr style="font-size:10px"><td style="color:{series.color};padding:0">{series.name}: </td>' + '<td style="padding:0"><b>{point.y}</b> Руб.</td></tr>',
			  footerFormat: '</table>',
			  shared: true,
			  useHTML: true
		    },
		    plotOptions: {
			  areaspline: {
			    fillOpacity: 0.5
			  }
		    },
		    series: [{
			  name: 'Введено',
			  data: [ <?=$history_reklama_pay7['sum']?>, <?=$history_reklama_pay6['sum']?>, <?=$history_reklama_pay5['sum']?>, <?=$history_reklama_pay4['sum']?>, <?=$history_reklama_pay3['sum']?>, <?=$history_reklama_pay2['sum']?>, <?=$history_reklama_pay1['sum']?> ],
			  text: 'р',
			  color: '#333'
		    }, {
			  name: 'Выведено',
			  data: [ <?=$pay_history7['sum']?>, <?=$pay_history6['sum']?>, <?=$pay_history5['sum']?>, <?=$pay_history4['sum']?>, <?=$pay_history3['sum']?>, <?=$pay_history2['sum']?>, <?=$pay_history1['sum']?> ],
			  text: 'уцкцур',
			  color: '#CD5C5C'
		    }]
		  });
		
	    });
	  </script>
      <div id="moneycnt" style="width: <?= ( int ) $width?>px; height: <?= ( int ) $height?>px; margin-left: 35px;"></div>
    <? 
  } 

  function adv_statistic( $user, $width, $height ) {
  
    #Сума прибили от рефералов 1 и 2 уровней.
    $sumref1g = mysql_fetch_array( mysql_query( "SELECT SUM(toref) as sum FROM user WHERE referer = '" .  ( int ) $user  . "'" ) );
    if ( $sumref1g['sum'] == '' ) {
      $sumref1g['sum'] = '0.0000';
    }
    $sumref2g = mysql_fetch_array( mysql_query( "SELECT SUM(toref2) as sum FROM user WHERE referer2 = '" .  ( int ) $user  . "'" ) );
    if ( $sumref2g['sum'] == '' ) {
      $sumref2g['sum'] = '0.0000';
    }   
    $earnings_ref = $sumref1g['sum'] + $sumref2g['sum'];
  
    #Определяем другие типы зароботка
    $earnings_all = mysql_fetch_array( mysql_query( "SELECT * FROM user WHERE id = '" .  ( int ) $user  . "'" ) );
  
    ?>
	  <script type="text/javascript">
	    $(document).ready(function() {
		  
		  Highcharts.chart('advmoneycnt', {

		    title: {
			  text: ''
		    },
		
		    exporting: {
			  buttons: {
			    contextButton: {
				  enabled: false
			    }
			  }
		    },
		    credits: {
		      enabled: false
		    },
		    legend: {
		      enabled: false,
		      layout: 'horizontal',
		      align: 'left',
		      verticalAlign: 'top',
		      x: 50,
		      y: 50,
		      floating: true,
		      borderWidth: 1,
		      backgroundColor: '#FFFFFF'
		    },
		
		    chart: {
		      backgroundColor: '#fff'
		    },

		    xAxis: {
		      categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
		    },
		
		    tooltip: {
		      headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
		      pointFormat: '<tr style="font-size:10px"><td style="color:{series.color};padding:0">{series.name}: </td>' + '<td style="padding:0"><b>{point.y}</b> Руб.</td></tr>',
		      footerFormat: '</table>',
		      shared: true,
		      useHTML: true
		    },

		    series: [{
		      type: 'pie',
		      allowPointSelect: true,
		      keys: ['name', 'y', 'selected', 'sliced'],
		      data: [
			    ['Серфинг', <?=$earnings_all['earnings_serf']?>, false],
			    ['Автосерфинг', <?=$earnings_all['earnings_auto']?>, false],
			    ['Тесты', <?=$earnings_all['earnings_test']?>, false],
			    ['Задания', <?=$earnings_all['earnings_task']?>, false],
			    ['Вконтакте', <?=$earnings_all['earnings_vk']?>, false],
			    ['Ютуб', <?=$earnings_all['earnings_youtube']?>, false],
			    ['Конкурсы', <?=$earnings_all['earnings_competition']?>, false],
			    ['Бонусы', <?=$earnings_all['earnings_bonus']?>, false],
			    ['Ярмарка', <?=$earnings_all['earnings_fair']?>, false],
			    ['Рефералы', <?=$earnings_ref?>, false]
		      ],
		      showInLegend: true
		    }]
	      });
		
	    });
	  </script>
	  <div id="advmoneycnt" style="width: <?= ( int ) $width?>px; height: <?= ( int ) $height?>px; margin-left: 395px; margin-top: -250px;"></div>
	
    <? 
  } 
?>