<?
### Версия ПО (ДМ) 1.0.0.0 ( (c)2018 MISOFT Продукт защищен регистрацией патента и авторских прав! www.misoft.studio )
######################################################################################################################

if ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) {
  define( 'ROOT_DIR', $_SERVER['DOCUMENT_ROOT'] );
  session_start();
  header( 'Content-type: text/html; charset=windows-1251' );
  include_once ROOT_DIR . '/engine/config.php';
  include_once ROOT_DIR . '/engine/function.php';
} else {
   if ( !defined( 'MISOFT' ) ) { exit(); }
}

if ( !isset( $_SESSION['iduser'] ) ) {
    echo '<div class="error" style="width: 90%; margin: 10px auto; text-align: center"><b>Ошибка!</b> Вы не авторизированы.<br />пожалуйста, воспользуйтесь формой авторизации.</div>';
} else {
	
	$page_redirect = check_text( $_GET['type'] );
    ?>
	<div style="margin-left: -10px;">
	  <a href="/mstatistic" class="content_bar_buttom">СТАТИСТИКА</a>
	  <a href="/operation" class="content_bar_buttom1_act">ИСТОРИЯ ОПЕРАЦИЙ</a>
    </div>
	<div class="content_bar content_bar_margin">
      <article class="postBox">
	    <div class="h2-title-header"><h2><a>История операций</a></h2></div>
	    <div class="image_history_p"></div>
	    <div class="textPreview" style="padding: 0 20px 0 0;">
	      <p class="earnings_text" style="color: #545454;">
		    Иногда очень нужно отследить какую-то операцию, особенно когда это касается финансовых операций. Здесь вы можете отследить свои финансовые операции по рекламных кампаниях, ярмарке, рефералам, пополнению счета и вывода денег с проекта.  
	      </p>
	    </div>
		
		<? include_once ROOT_DIR . '/modules/history/menu.php'; ?>
	    
		<table class="standartTable" >
		  <thead>
		    <th style="text-align: center; ">Параметр операции</th>
		    <th style="text-align: center;">Дата</th>
		    <th style="text-align: center; ">Сумма</th>
		    <th style="text-align: center; ">Тип платежа</th>
		    <th style="text-align: center; ">Действие</th>
		  </thead>
	      <?
	        #История серфинга
		    if ( $_GET['type'] == 'serfing' ) {
			  $get_history_temp = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 0 and iduser = '" . $_SESSION['iduser'] . "'" );
			  
			  #Считаем количество страниц для навигации.
			  $kolvo = 15;
			  $all = mysql_num_rows( $get_history_temp );
			  $allpage = ceil( $all / $kolvo );
			  $this_page = ( isset( $_GET['page'] ) ) ? intval( $_GET['page'] ) : 1 ;
			  if ( $this_page < 1 ) $this_page = 1;
			  if ( $this_page > $allpage ) $this_page = $allpage;
			  $start = $this_page * $kolvo - $kolvo;
			  if ( $start == -$kolvo ) { $start = 1; }
				
			  $get_history = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 0 and iduser = '" . $_SESSION['iduser'] . "' ORDER BY date DESC LIMIT $start,$kolvo" );
			
			  if ( mysql_num_rows( $get_history ) > 0 ) {
			    while ( $get_history_row = mysql_fetch_array( $get_history ) ) {
				  $month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
				  $mess_time = ( int ) date( 'd', $get_history_row['date'] ) . ' ' . $month[( int ) date( 'm', $get_history_row['date'] ) - 1] . ' ' . date( 'Y', $get_history_row['date'] )  . ' в ' . date( 'H:i', $get_history_row['date'] );
				
				  switch ( $get_history_row['payopt'] ) {
				    case 0:
					  $payed = 'рекламный счет';
					  break;
				    case 1:
					  $payed = '<span style="color:#4769a3">webmoney</span>';
					  break;
				    case 2:
					  $payed = '<span style="color:#000000"><span style="color:#ff0000">я</span>ндекс.деньги</span>';
					  break;
				    case 3:
					  $payed = '<span style="color:#AF0032">кешбэк </span>';
					  break;
				    case 4:
					  $payed = '<span style="color:#03a9f4">payeer</span>';
					  break;	
				    case 5:
					  $payed = '<span style="color:#009688">робокасса</span>';
					  break;
				    case 6:
					  $payed = '<span style="color:#0FA000">advcash</span>';
					  break;
				    case 7:
					  $payed = '<span style="color:#FF5226">walletone</span>';
					  break;
				    case 8:
					  $payed = '<span style="color:#00A6E6">megakassa</span>';
					  break;
				  }
				  ?>
				    <tr>
				      <td style="text-align: center;"><?=$get_history_row['h_text']?> </td>
				      <td style="text-align: center;"><?=$mess_time?> </td>
				      <td style="text-align: center;"><?=$get_history_row['price'] . ' ' . $config['valutaname']?> </td>
				      <td style="text-align: center;"><?=$payed?></td>
				      <td style="text-align: center;">
					    <button type="button" class="btn btn-danger btn-sm" style="height: 10px; padding-top: 1px; padding-bottom: 6px; font-size: 12px;" onclick="delHistory(<?=$get_history_row['id']?>, 0);">удалить</button>
					  </td>
				    </tr>
				  <?
			    }
			  } else {
				echo '<tr><td colspan="5" style="text-align: center;">Записей не найдено! </td></tr>'; 
			  }
		    } else
			#История авто-серфинга
		    if ( $_GET['type'] == 'autoserfing' ) {
			  $get_history_temp = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 16 and iduser = '" . $_SESSION['iduser'] . "'" );
			  
			  #Считаем количество страниц для навигации.
			  $kolvo = 15;
			  $all = mysql_num_rows( $get_history_temp );
			  $allpage = ceil( $all / $kolvo );
			  $this_page = ( isset( $_GET['page'] ) ) ? intval( $_GET['page'] ) : 1 ;
			  if ( $this_page < 1 ) $this_page = 1;
			  if ( $this_page > $allpage ) $this_page = $allpage;
			  $start = $this_page * $kolvo - $kolvo;
			  if ( $start == -$kolvo ) { $start = 1; }
				
			  $get_history = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 16 and iduser = '" . $_SESSION['iduser'] . "' ORDER BY date DESC LIMIT $start,$kolvo" );
			
			  if ( mysql_num_rows( $get_history ) > 0 ) {
			    while ( $get_history_row = mysql_fetch_array( $get_history ) ) {
				  $month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
				  $mess_time = ( int ) date( 'd', $get_history_row['date'] ) . ' ' . $month[( int ) date( 'm', $get_history_row['date'] ) - 1] . ' ' . date( 'Y', $get_history_row['date'] )  . ' в ' . date( 'H:i', $get_history_row['date'] );
				
				  switch ( $get_history_row['payopt'] ) {
				    case 0:
					  $payed = 'рекламный счет';
					  break;
				    case 1:
					  $payed = '<span style="color:#4769a3">webmoney</span>';
					  break;
				    case 2:
					  $payed = '<span style="color:#000000"><span style="color:#ff0000">я</span>ндекс.деньги</span>';
					  break;
				    case 3:
					  $payed = '<span style="color:#AF0032">кешбэк </span>';
					  break;
				    case 4:
					  $payed = '<span style="color:#03a9f4">payeer</span>';
					  break;	
				    case 5:
					  $payed = '<span style="color:#009688">робокасса</span>';
					  break;
				    case 6:
					  $payed = '<span style="color:#0FA000">advcash</span>';
					  break;
				    case 7:
					  $payed = '<span style="color:#FF5226">walletone</span>';
					  break;
				    case 8:
					  $payed = '<span style="color:#00A6E6">megakassa</span>';
					  break;
				  }
				  ?>
				    <tr>
				      <td style="text-align: center;"><?=$get_history_row['h_text']?> </td>
				      <td style="text-align: center;"><?=$mess_time?> </td>
				      <td style="text-align: center;"><?=$get_history_row['price'] . ' ' . $config['valutaname']?> </td>
				      <td style="text-align: center;"><?=$payed?></td>
				      <td style="text-align: center;">
					    <button type="button" class="btn btn-danger btn-sm" style="height: 10px; padding-top: 1px; padding-bottom: 6px; font-size: 12px;" onclick="delHistory(<?=$get_history_row['id']?>, 0);">удалить</button>
					  </td>
				    </tr>
				  <?
			    }
			  } else {
				echo '<tr><td colspan="5" style="text-align: center;">Записей не найдено! </td></tr>'; 
			  }
		    } else
			#История контекстной рекламы
			if ( $_GET['type'] == 'klink' ) {
			  
			  $get_history_temp = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 1 and iduser = '" . $_SESSION['iduser'] . "'" );
			  
			  #Считаем количество страниц для навигации.
			  $kolvo = 15;
			  $all = mysql_num_rows( $get_history_temp );
			  $allpage = ceil( $all / $kolvo );
			  $this_page = ( isset( $_GET['page'] ) ) ? intval( $_GET['page'] ) : 1 ;
			  if ( $this_page < 1 ) $this_page = 1;
			  if ( $this_page > $allpage ) $this_page = $allpage;
			  $start = $this_page * $kolvo - $kolvo;
			  if ( $start == -$kolvo ) { $start = 1; }
			  
			  $get_history = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 1 and iduser = '" . $_SESSION['iduser'] . "' ORDER BY date DESC LIMIT $start,$kolvo" );
			
			  if ( mysql_num_rows( $get_history ) > 0 ) {
				while ( $get_history_row = mysql_fetch_array( $get_history ) ) {
				  $month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
				  $mess_time = ( int ) date( 'd', $get_history_row['date'] ) . ' ' . $month[( int ) date( 'm', $get_history_row['date'] ) - 1] . ' ' . date( 'Y', $get_history_row['date'] )  . ' в ' . date( 'H:i', $get_history_row['date'] );
				
				  switch ( $get_history_row['payopt'] ) {
				    case 0:
					  $payed = 'рекламный счет';
					  break;
				    case 1:
					  $payed = '<span style="color:#4769a3">webmoney</span>';
					  break;
				    case 2:
					  $payed = '<span style="color:#000000"><span style="color:#ff0000">я</span>ндекс.деньги</span>';
					  break;
				    case 3:
					  $payed = '<span style="color:#AF0032">кешбэк </span>';
					  break;
				    case 4:
					  $payed = '<span style="color:#03a9f4">payeer</span>';
					  break;	
				    case 5:
					  $payed = '<span style="color:#009688">робокасса</span>';
					  break;
				    case 6:
					  $payed = '<span style="color:#0FA000">advcash</span>';
					  break;
				    case 7:
					  $payed = '<span style="color:#FF5226">walletone</span>';
					  break;
				    case 8:
					  $payed = '<span style="color:#00A6E6">megakassa</span>';
					  break;
				  }
				
				  ?>
				    <tr>
				      <td style="text-align: center;"><?=$get_history_row['h_text']?> </td>
				      <td style="text-align: center;"><?=$mess_time?> </td>
				      <td style="text-align: center;"><?=$get_history_row['price'] . ' ' . $config['valutaname']?> </td>
				      <td style="text-align: center;"><?=$payed?></td>
				      <td style="text-align: center;">
					    <button type="button" class="btn btn-danger btn-sm" style="height: 10px; padding-top: 1px; padding-bottom: 6px; font-size: 12px;" onclick="delHistory(<?=$get_history_row['id']?>, 1);">удалить</button>
					  </td>
				    </tr>
				  <?
			    }
			  } else {
				echo '<tr><td colspan="5" style="text-align: center;">Записей не найдено! </td></tr>'; 
			  }
			} else
			#История статичиской рекламы
			if ( $_GET['type'] == 'statlink' ) {
			  
			  $get_history_temp = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 20 and iduser = '" . $_SESSION['iduser'] . "'" );
			  
			  #Считаем количество страниц для навигации.
			  $kolvo = 15;
			  $all = mysql_num_rows( $get_history_temp );
			  $allpage = ceil( $all / $kolvo );
			  $this_page = ( isset( $_GET['page'] ) ) ? intval( $_GET['page'] ) : 1 ;
			  if ( $this_page < 1 ) $this_page = 1;
			  if ( $this_page > $allpage ) $this_page = $allpage;
			  $start = $this_page * $kolvo - $kolvo;
			  if ( $start == -$kolvo ) { $start = 1; }
			  
			  $get_history = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 20 and iduser = '" . $_SESSION['iduser'] . "' ORDER BY date DESC LIMIT $start,$kolvo" );
			
			  if ( mysql_num_rows( $get_history ) > 0 ) {
				while ( $get_history_row = mysql_fetch_array( $get_history ) ) {
				  $month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
				  $mess_time = ( int ) date( 'd', $get_history_row['date'] ) . ' ' . $month[( int ) date( 'm', $get_history_row['date'] ) - 1] . ' ' . date( 'Y', $get_history_row['date'] )  . ' в ' . date( 'H:i', $get_history_row['date'] );
				
				  switch ( $get_history_row['payopt'] ) {
					case 0:
						$payed = 'рекламный счет';
						break;
					case 1:
						$payed = '<span style="color:#4769a3">webmoney</span>';
						break;
					case 2:
						$payed = '<span style="color:#000000"><span style="color:#ff0000">я</span>ндекс.деньги</span>';
						break;
					case 3:
						$payed = '<span style="color:#AF0032">кешбэк </span>';
						break;
					case 4:
						$payed = '<span style="color:#03a9f4">payeer</span>';
						break;	
					case 5:
						$payed = '<span style="color:#009688">робокасса</span>';
						break;
					case 6:
						$payed = '<span style="color:#0FA000">advcash</span>';
						break;
					case 7:
						$payed = '<span style="color:#FF5226">walletone</span>';
						break;
					case 8:
						$payed = '<span style="color:#00A6E6">megakassa</span>';
						break;
				  }
				
				  ?>
				    <tr>
				      <td style="text-align: center;"><?=$get_history_row['h_text']?> </td>
				      <td style="text-align: center;"><?=$mess_time?> </td>
				      <td style="text-align: center;"><?=$get_history_row['price'] . ' ' . $config['valutaname']?> </td>
				      <td style="text-align: center;"><?=$payed?></td>
				      <td style="text-align: center;">
					    <button type="button" class="btn btn-danger btn-sm" style="height: 10px; padding-top: 1px; padding-bottom: 6px; font-size: 12px;" onclick="delHistory(<?=$get_history_row['id']?>, 20);">удалить</button>
					  </td>
				    </tr>
				  <?
				}
			  } else {
				echo '<tr><td colspan="5" style="text-align: center;">Записей не найдено! </td></tr>'; 
			  }
			} else
			#История рекламной цепочки
			if ( $_GET['type'] == 'chain' ) {
			  
			  $get_history_temp = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 18 and iduser = '" . $_SESSION['iduser'] . "'" );
			  
			  #Считаем количество страниц для навигации.
			  $kolvo = 15;
			  $all = mysql_num_rows( $get_history_temp );
			  $allpage = ceil( $all / $kolvo );
			  $this_page = ( isset( $_GET['page'] ) ) ? intval( $_GET['page'] ) : 1 ;
			  if ( $this_page < 1 ) $this_page = 1;
			  if ( $this_page > $allpage ) $this_page = $allpage;
			  $start = $this_page * $kolvo - $kolvo;
			  if ( $start == -$kolvo ) { $start = 1; }
			  
			  $get_history = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 18 and iduser = '" . $_SESSION['iduser'] . "' ORDER BY date DESC LIMIT $start,$kolvo" );
			
			  if ( mysql_num_rows( $get_history ) > 0 ) {
				while ( $get_history_row = mysql_fetch_array( $get_history ) ) {
				  $month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
				  $mess_time = ( int ) date( 'd', $get_history_row['date'] ) . ' ' . $month[( int ) date( 'm', $get_history_row['date'] ) - 1] . ' ' . date( 'Y', $get_history_row['date'] )  . ' в ' . date( 'H:i', $get_history_row['date'] );
				
				  switch ( $get_history_row['payopt'] ) {
					case 0:
						$payed = 'рекламный счет';
						break;
					case 1:
						$payed = '<span style="color:#4769a3">webmoney</span>';
						break;
					case 2:
						$payed = '<span style="color:#000000"><span style="color:#ff0000">я</span>ндекс.деньги</span>';
						break;
					case 3:
						$payed = '<span style="color:#AF0032">кешбэк </span>';
						break;
					case 4:
						$payed = '<span style="color:#03a9f4">payeer</span>';
						break;	
					case 5:
						$payed = '<span style="color:#009688">робокасса</span>';
						break;
					case 6:
						$payed = '<span style="color:#0FA000">advcash</span>';
						break;
					case 7:
						$payed = '<span style="color:#FF5226">walletone</span>';
						break;
					case 8:
						$payed = '<span style="color:#00A6E6">megakassa</span>';
						break;
				  }
				
				  ?>
				    <tr>
				      <td style="text-align: center;"><?=$get_history_row['h_text']?> </td>
				      <td style="text-align: center;"><?=$mess_time?> </td>
				      <td style="text-align: center;"><?=$get_history_row['price'] . ' ' . $config['valutaname']?> </td>
				      <td style="text-align: center;"><?=$payed?></td>
				      <td style="text-align: center;">
					    <button type="button" class="btn btn-danger btn-sm" style="height: 10px; padding-top: 1px; padding-bottom: 6px; font-size: 12px;" onclick="delHistory(<?=$get_history_row['id']?>, 18);">удалить</button>
					  </td>
				    </tr>
				  <?
				}
			  } else {
				echo '<tr><td colspan="5" style="text-align: center;">Записей не найдено! </td></tr>'; 
			  }
			} else
			#История баннеры
			if ( $_GET['type'] == 'banners' ) {
			  
			  $get_history_temp = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 3 and iduser = '" . $_SESSION['iduser'] . "'" );
			  
			  #Считаем количество страниц для навигации.
			  $kolvo = 15;
			  $all = mysql_num_rows( $get_history_temp );
			  $allpage = ceil( $all / $kolvo );
			  $this_page = ( isset( $_GET['page'] ) ) ? intval( $_GET['page'] ) : 1 ;
			  if ( $this_page < 1 ) $this_page = 1;
			  if ( $this_page > $allpage ) $this_page = $allpage;
			  $start = $this_page * $kolvo - $kolvo;
			  if ( $start == -$kolvo ) { $start = 1; }
			  
			  $get_history = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 3 and iduser = '" . $_SESSION['iduser'] . "' ORDER BY date DESC LIMIT $start,$kolvo" );
			
			  if ( mysql_num_rows( $get_history ) > 0 ) {
				while ( $get_history_row = mysql_fetch_array( $get_history ) ) {
				  $month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
				  $mess_time = ( int ) date( 'd', $get_history_row['date'] ) . ' ' . $month[( int ) date( 'm', $get_history_row['date'] ) - 1] . ' ' . date( 'Y', $get_history_row['date'] )  . ' в ' . date( 'H:i', $get_history_row['date'] );
				
				  switch ( $get_history_row['payopt'] ) {
					case 0:
						$payed = 'рекламный счет';
						break;
					case 1:
						$payed = '<span style="color:#4769a3">webmoney</span>';
						break;
					case 2:
						$payed = '<span style="color:#000000"><span style="color:#ff0000">я</span>ндекс.деньги</span>';
						break;
					case 3:
						$payed = '<span style="color:#AF0032">кешбэк </span>';
						break;
					case 4:
						$payed = '<span style="color:#03a9f4">payeer</span>';
						break;	
					case 5:
						$payed = '<span style="color:#009688">робокасса</span>';
						break;
					case 6:
						$payed = '<span style="color:#0FA000">advcash</span>';
						break;
					case 7:
						$payed = '<span style="color:#FF5226">walletone</span>';
						break;
					case 8:
						$payed = '<span style="color:#00A6E6">megakassa</span>';
						break;
				  }
				
				  ?>
				    <tr>
				      <td style="text-align: center;"><?=$get_history_row['h_text']?> </td>
				      <td style="text-align: center;"><?=$mess_time?> </td>
				      <td style="text-align: center;"><?=$get_history_row['price'] . ' ' . $config['valutaname']?> </td>
				      <td style="text-align: center;"><?=$payed?></td>
				      <td style="text-align: center;">
					    <button type="button" class="btn btn-danger btn-sm" style="height: 10px; padding-top: 1px; padding-bottom: 6px; font-size: 12px;" onclick="delHistory(<?=$get_history_row['id']?>, 3);">удалить</button>
					  </td>
				    </tr>
				  <?
				}
			  } else {
				echo '<tr><td colspan="5" style="text-align: center;">Записей не найдено! </td></tr>'; 
			  }
			} else
			#История тесты
			if ( $_GET['type'] == 'tests' ) {
			  
			  $get_history_temp = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 2 and iduser = '" . $_SESSION['iduser'] . "'" );
			  
			  #Считаем количество страниц для навигации.
			  $kolvo = 15;
			  $all = mysql_num_rows( $get_history_temp );
			  $allpage = ceil( $all / $kolvo );
			  $this_page = ( isset( $_GET['page'] ) ) ? intval( $_GET['page'] ) : 1 ;
			  if ( $this_page < 1 ) $this_page = 1;
			  if ( $this_page > $allpage ) $this_page = $allpage;
			  $start = $this_page * $kolvo - $kolvo;
			  if ( $start == -$kolvo ) { $start = 1; }
			  
			  $get_history = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 2 and iduser = '" . $_SESSION['iduser'] . "' ORDER BY date DESC LIMIT $start,$kolvo" );
			
			  if ( mysql_num_rows( $get_history ) > 0 ) {
				while ( $get_history_row = mysql_fetch_array( $get_history ) ) {
				  $month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
				  $mess_time = ( int ) date( 'd', $get_history_row['date'] ) . ' ' . $month[( int ) date( 'm', $get_history_row['date'] ) - 1] . ' ' . date( 'Y', $get_history_row['date'] )  . ' в ' . date( 'H:i', $get_history_row['date'] );
				
				  switch ( $get_history_row['payopt'] ) {
					case 0:
						$payed = 'рекламный счет';
						break;
					case 1:
						$payed = '<span style="color:#4769a3">webmoney</span>';
						break;
					case 2:
						$payed = '<span style="color:#000000"><span style="color:#ff0000">я</span>ндекс.деньги</span>';
						break;
					case 3:
						$payed = '<span style="color:#AF0032">кешбэк </span>';
						break;
					case 4:
						$payed = '<span style="color:#03a9f4">payeer</span>';
						break;	
					case 5:
						$payed = '<span style="color:#009688">робокасса</span>';
						break;
					case 6:
						$payed = '<span style="color:#0FA000">advcash</span>';
						break;
					case 7:
						$payed = '<span style="color:#FF5226">walletone</span>';
						break;
					case 8:
						$payed = '<span style="color:#00A6E6">megakassa</span>';
						break;
				  }
				
				  ?>
				    <tr>
				      <td style="text-align: center;"><?=$get_history_row['h_text']?> </td>
				      <td style="text-align: center;"><?=$mess_time?> </td>
				      <td style="text-align: center;"><?=$get_history_row['price'] . ' ' . $config['valutaname']?> </td>
				      <td style="text-align: center;"><?=$payed?></td>
				      <td style="text-align: center;">
					    <button type="button" class="btn btn-danger btn-sm" style="height: 10px; padding-top: 1px; padding-bottom: 6px; font-size: 12px;" onclick="delHistory(<?=$get_history_row['id']?>, 2);">удалить</button>
					  </td>
				    </tr>
				  <?
				}
			  } else {
				echo '<tr><td colspan="5" style="text-align: center;">Записей не найдено! </td></tr>'; 
			  }
			} else
			#История задания
			if ( $_GET['type'] == 'tasks' ) {
			  
			  $get_history_temp = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 4 and iduser = '" . $_SESSION['iduser'] . "'" );
			  
			  #Считаем количество страниц для навигации.
			  $kolvo = 15;
			  $all = mysql_num_rows( $get_history_temp );
			  $allpage = ceil( $all / $kolvo );
			  $this_page = ( isset( $_GET['page'] ) ) ? intval( $_GET['page'] ) : 1 ;
			  if ( $this_page < 1 ) $this_page = 1;
			  if ( $this_page > $allpage ) $this_page = $allpage;
			  $start = $this_page * $kolvo - $kolvo;
			  if ( $start == -$kolvo ) { $start = 1; }
			  
			  $get_history = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 4 and iduser = '" . $_SESSION['iduser'] . "' ORDER BY date DESC LIMIT $start,$kolvo" );
			
			  if ( mysql_num_rows( $get_history ) > 0 ) {
				while ( $get_history_row = mysql_fetch_array( $get_history ) ) {
				  $month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
				  $mess_time = ( int ) date( 'd', $get_history_row['date'] ) . ' ' . $month[( int ) date( 'm', $get_history_row['date'] ) - 1] . ' ' . date( 'Y', $get_history_row['date'] )  . ' в ' . date( 'H:i', $get_history_row['date'] );
				
				  switch ( $get_history_row['payopt'] ) {
					case 0:
						$payed = 'рекламный счет';
						break;
					case 1:
						$payed = '<span style="color:#4769a3">webmoney</span>';
						break;
					case 2:
						$payed = '<span style="color:#000000"><span style="color:#ff0000">я</span>ндекс.деньги</span>';
						break;
					case 3:
						$payed = '<span style="color:#AF0032">кешбэк </span>';
						break;
					case 4:
						$payed = '<span style="color:#03a9f4">payeer</span>';
						break;	
					case 5:
						$payed = '<span style="color:#009688">робокасса</span>';
						break;
					case 6:
						$payed = '<span style="color:#0FA000">advcash</span>';
						break;
					case 7:
						$payed = '<span style="color:#FF5226">walletone</span>';
						break;
					case 8:
						$payed = '<span style="color:#00A6E6">megakassa</span>';
						break;
				  }
				
				  ?>
					<tr>
				      <td style="text-align: center;"><?=$get_history_row['h_text']?> </td>
				      <td style="text-align: center;"><?=$mess_time?> </td>
				      <td style="text-align: center;"><?=$get_history_row['price'] . ' ' . $config['valutaname']?> </td>
				      <td style="text-align: center;"><?=$payed?></td>
				      <td style="text-align: center;">
					    <button type="button" class="btn btn-danger btn-sm" style="height: 10px; padding-top: 1px; padding-bottom: 6px; font-size: 12px;" onclick="delHistory(<?=$get_history_row['id']?>, 4);">удалить</button>
					  </td>
				    </tr>
				  <?
				}
			  } else {
				echo '<tr><td colspan="5" style="text-align: center;">Записей не найдено! </td></tr>'; 
			  }
			} else
			#История выплат
			if ( $_GET['type'] == 'pay' ) {
			  
			  $get_history_temp = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 5 and iduser = '" . $_SESSION['iduser'] . "'" );
			  
			  #Считаем количество страниц для навигации.
			  $kolvo = 15;
			  $all = mysql_num_rows( $get_history_temp );
			  $allpage = ceil( $all / $kolvo );
			  $this_page = ( isset( $_GET['page'] ) ) ? intval( $_GET['page'] ) : 1 ;
			  if ( $this_page < 1 ) $this_page = 1;
			  if ( $this_page > $allpage ) $this_page = $allpage;
			  $start = $this_page * $kolvo - $kolvo;
			  if ( $start == -$kolvo ) { $start = 1; }
			  
			  $get_history = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 5 and iduser = '" . $_SESSION['iduser'] . "' ORDER BY date DESC LIMIT $start,$kolvo" );
			
			  if ( mysql_num_rows( $get_history ) > 0 ) {
				while ( $get_history_row = mysql_fetch_array( $get_history ) ) {
				  $month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
				  $mess_time = ( int ) date( 'd', $get_history_row['date'] ) . ' ' . $month[( int ) date( 'm', $get_history_row['date'] ) - 1] . ' ' . date( 'Y', $get_history_row['date'] )  . ' в ' . date( 'H:i', $get_history_row['date'] );
				
				  switch ( $get_history_row['payopt'] ) {
					case 0:
						$payed = 'рекламный счет';
						break;
					case 1:
						$payed = '<span style="color:#4769a3">webmoney</span>';
						break;
					case 2:
						$payed = '<span style="color:#000000"><span style="color:#ff0000">я</span>ндекс.деньги</span>';
						break;
					case 3:
						$payed = '<span style="color:#AF0032">кешбэк </span>';
						break;
					case 4:
						$payed = '<span style="color:#03a9f4">payeer</span>';
						break;	
					case 5:
						$payed = '<span style="color:#009688">робокасса</span>';
						break;
					case 6:
						$payed = '<span style="color:#0FA000">advcash</span>';
						break;
					case 7:
						$payed = '<span style="color:#FF5226">walletone</span>';
						break;
					case 8:
						$payed = '<span style="color:#00A6E6">megakassa</span>';
						break;
				  }
				
				  ?>
					<tr>
				      <td style="text-align: center;"><?=$get_history_row['h_text']?> </td>
				      <td style="text-align: center;"><?=$mess_time?> </td>
				      <td style="text-align: center;"><?=$get_history_row['price'] . ' ' . $config['valutaname']?> </td>
				      <td style="text-align: center;"><?=$payed?></td>
				      <td style="text-align: center;">
					    <button type="button" class="btn btn-danger btn-sm" style="height: 10px; padding-top: 1px; padding-bottom: 6px; font-size: 12px;" onclick="delHistory(<?=$get_history_row['id']?>, 5);">удалить</button>
					  </td>
				    </tr>
				  <?
				}
			  } else {
				echo '<tr><td colspan="5" style="text-align: center;">Записей не найдено! </td></tr>'; 
			  }
			} else
			
			#История ярмарки
			if ( $_GET['type'] == 'fair' ) {
			  
			  $get_history_temp = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 14 and iduser = '" . $_SESSION['iduser'] . "'" );
			  
			  #Считаем количество страниц для навигации.
			  $kolvo = 15;
			  $all = mysql_num_rows( $get_history_temp );
			  $allpage = ceil( $all / $kolvo );
			  $this_page = ( isset( $_GET['page'] ) ) ? intval( $_GET['page'] ) : 1 ;
			  if ( $this_page < 1 ) $this_page = 1;
			  if ( $this_page > $allpage ) $this_page = $allpage;
			  $start = $this_page * $kolvo - $kolvo;
			  if ( $start == -$kolvo ) { $start = 1; }
			  
			  $get_history = mysql_query( "SELECT * FROM history_reklama_pay WHERE type = 14 and iduser = '" . $_SESSION['iduser'] . "' ORDER BY date DESC LIMIT $start,$kolvo" );
			
			  if ( mysql_num_rows( $get_history ) > 0 ) {
				while ( $get_history_row = mysql_fetch_array( $get_history ) ) {
				  $month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
				  $mess_time = ( int ) date( 'd', $get_history_row['date'] ) . ' ' . $month[( int ) date( 'm', $get_history_row['date'] ) - 1] . ' ' . date( 'Y', $get_history_row['date'] )  . ' в ' . date( 'H:i', $get_history_row['date'] );
				  
				  switch ( $get_history_row['payopt'] ) {
				    case 0:
					  $payed = 'рекламный счет';
					  break;
				    case 1:
					  $payed = '<span style="color:#4769a3">webmoney</span>';
					  break;
				    case 2:
					  $payed = '<span style="color:#000000"><span style="color:#ff0000">я</span>ндекс.деньги</span>';
					  break;
				    case 3:
					  $payed = '<span style="color:#AF0032">кешбэк </span>';
					  break;
				    case 4:
					  $payed = '<span style="color:#03a9f4">payeer</span>';
					  break;	
				    case 5:
					  $payed = '<span style="color:#009688">робокасса</span>';
					  break;
				    case 6:
					  $payed = '<span style="color:#0FA000">advcash</span>';
					  break;
				    case 7:
					  $payed = '<span style="color:#FF5226">walletone</span>';
					  break;
				    case 8:
					  $payed = '<span style="color:#00A6E6">megakassa</span>';
					  break;
					default : 
					  $payed = '-';
					break;
				  }
				  ?>
				    <tr>
				      <td style="text-align: center;"><?=$get_history_row['h_text']?> </td>
				      <td style="text-align: center;"><?=$mess_time?> </td>
				      <td style="text-align: center;"><?=$get_history_row['price'] . ' ' . $config['valutaname']?> </td>
				      <td style="text-align: center;"><?=$payed?></td>
				      <td style="text-align: center;">
					    <button type="button" class="btn btn-danger btn-sm" style="height: 10px; padding-top: 1px; padding-bottom: 6px; font-size: 12px;" onclick="delHistory(<?=$get_history_row['id']?>, 14);">удалить</button>
					  </td>
				    </tr>
				  <?
				}
			  } else {
				echo '<tr><td colspan="5" style="text-align: center;">Записей не найдено! </td></tr>'; 
			  }
				
			}
		   ?>
        </table>
		<div class="div_centralizator"><?=navigation( 15, ( int ) $_GET['page'], mysql_num_rows( $get_history_temp ), 'history='.$page_redirect.'&p=' )?></div>
      </article>
    </div>	
   <?
  }


?>