<?
  ### Версия ПО (ДМ) 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();
    include_once ROOT_DIR . '/engine/config.php';
    include_once ROOT_DIR . '/engine/function.php';
  } else {
    if ( !defined( 'MISOFT' ) ) { exit(); }
  }

  include_once ROOT_DIR . '/modules/global_competition/menu.php';
?>

<div class="content_bar">
  <article class="postBox">
		
	<div class="h2-title-header"><h2><a>Конкурсы проекта</a></h2></div>
	<div class="image_global_competition_p"></div>
	<div class="textPreview" style="">
	  <p class="earnings_text" style="color: #545454;">
		Участвуя в конкурсах от системы, вы можете не плохо заработать, а также заявить о себе другим участникам проекта, в системе доступны несколько типов конкурсов, наверняка что-то найдется и для вас, не теряйте времени! Внимание, любые накрутки и манипуляции с системой будут наказаны безвозвратной блокировкой аккаунта! Мы за справедливое сражение!
	  </p>
	</div>

	<div class="competition-type"><i class="fa fa-list-alt" aria-hidden="true"></i> Конкурс рекламодателя</div>
	<?
	$checkKonkurs = mysql_query( "SELECT * FROM konkurs WHERE type = 0 LIMIT 1" );
	if ( !mysql_num_rows( $checkKonkurs ) ) {
	 ?>
	  <div class="alert alert-info" role="alert">
		Внимание! В данный момент конкурс не активный!
	  </div>
	 <?
	} else {
	  #Задаем количество мест по умолчанию.
	  $number_of_seats = 3;
	 ?>
	  <div class="competition-show">
	    <?
	      $checkKonkursRow = mysql_fetch_array( $checkKonkurs );
	      $month = array( 'января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря' );
	    ?>
		<table style="font-size: 14px;">
		  <tr>
			<td colspan="2"><div class="competition-show-name div_centralizator"><?=$checkKonkursRow['name']?></div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2"><div class="competition-show-text div_centralizator"><?=$checkKonkursRow['description']?></div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2"><div class="competition-show-min">Минимальный порог</br> <?=$checkKonkursRow['min_type']?> баллов</div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2">
			  <div class="competition-show-curs">Начисление:</br> 1 балл = 1 <?=$config['valutaname']?></div>
			  <div class="competition-show-button"><button type="button" class="btn btn-danger btn-sm" onclick="competition.complaints_adm(<?=$checkKonkursRow['id']?>, 'adv');">Сообщить о накрутке</button></div>
			</td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2">
			  <div class="competition-show-date">
			    <div class="">
				  Время проведения:
				  <div class="competition-show-date-icon"></div>
				</div>
			    <div class="competition-show-date-text">
				  <div class="">
				    <i class="fa fa-calendar" aria-hidden="true"></i> с <?=( int ) date ( 'd', $checkKonkursRow['date_start'] ) . ' ' . $month[( int ) date( 'm', $checkKonkursRow['date_start'] ) - 1] . ' ' . date( 'Y', $checkKonkursRow['date_start'] )?> г.
				  </div>
			      <div class="">
				    <i class="fa fa-calendar" aria-hidden="true"></i> по <?=( int ) date( 'd', $checkKonkursRow['date_end'] ) . ' ' . $month[( int ) date( 'm', $checkKonkursRow['date_end'] ) - 1] . ' ' . date( 'Y', $checkKonkursRow['date_end'] )?> г.
				  </div>
				</div>
			  </div>
			  <div class="competition-show-prizes">
			    <div class="competition-show-prizes-text">
				  <div class="competition-show-prizes-icon"></div>
				  Призы победителям:
				</div>
				<div class="competition-show-prizes-number">
				  <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_one.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow['priz1']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
			      <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_two.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow['priz2']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
			      <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_three.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow['priz3']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
				  <? if( $checkKonkursRow['priz4'] > 0 ) { 
				    $number_of_seats = 4;
				    ?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_four.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow['priz4']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow['priz5'] > 0 ) { 
				    $number_of_seats = 5;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_five.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow['priz5']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow['priz6'] > 0 ) { 
				     $number_of_seats = 6;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_six.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow['priz6']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow['priz7'] > 0 ) { 
				     $number_of_seats = 7;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_seven.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow['priz7']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow['priz8'] > 0 ) { 
				    $number_of_seats = 8;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_eight.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow['priz8']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow['priz9'] > 0 ) { 
				    $number_of_seats = 9;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_nine.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow['priz9']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow['priz10'] > 0 ) { 
				    $number_of_seats = 10;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_ten.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow['priz10']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } ?>
				</div>
			  </div>
			</td>
			<td></td>
		  </tr>
		</table>
	  </div>
	  <table class="standartTable" style="width: 747px; margin: 15px 0 0 15px;">
		<thead>
		  <th style="width: 30px;">Место</th>
		  <th style="text-align: left;">Участник</th>
		  <th style="text-align: center;">Статус</th>
		  <th style="width: 30px;">Баллы</th>
		</thead>
		<?
		  $i = 0;
		  $kon1 = mysql_query( "SELECT * FROM konkurs WHERE type = 0 LIMIT 1" );
		  if ( mysql_num_rows( $kon1 ) > 0 ) {
			$kon1Row = mysql_fetch_array( $kon1 );
			$kon1User = mysql_query( "SELECT iduser, summ FROM konkurs_temp WHERE id_konkurs = '" . $kon1Row['id'] . "' and type = '" . $kon1Row['type'] . "' and summ >= '" . $kon1Row['min_type'] . "' ORDER BY summ DESC" );
			while ( $kon1UserRow = mysql_fetch_array( $kon1User ) ) {
			  $i++;
			  $user = mysql_fetch_array( mysql_query( "SELECT id, username, avatar FROM user WHERE id = '" . $kon1UserRow['iduser'] . "' LIMIT 1" ) );
			  if ( $kon1Row['allsumm'] ) {
				if ( $i <= $number_of_seats ) {
				  $priz = '<div class="competition-priz-text">+' . $kon1Row['priz' . $i] * $kon1UserRow['summ'] . ' ' . $config['valutaname'] . '</div>';
				} else {
				  $priz = '';
				}
			  } else {
				if ( $i <= $number_of_seats ) {
				  $priz = '<div class="competition-priz-text">участвует, приз: ' . $kon1Row['priz' . $i] . '' . $config['valutaname'] . '</div>';
				} else {
				  $priz = '';
				}
			  }
		      ?>
				<tr>
				  <td style="text-align: center;"><?=$i?></td>
				  <td style="text-align: left;"><div style="position: relative;">
				    <a href="/id<?=$user['id']?>">
					  <img src="/temp/avatar/<?=$user['avatar']?>" class="img-circle competition-avatar-table" width="20" height="20" align="left" />
					</a>
					<?=$user['username']?></div>
				  </td>
				  <td style="text-align: center; width: 245px; padding: 0 0 0 0;" class=""><?=$priz?></td>
				  <td style="text-align: center;"><?=$kon1UserRow['summ']?></td>
				</tr>
			  <?
			}
		  }
		?>
	  </table></br>
	 <?
	}
	?>

	<div class="competition-type"><i class="fa fa-list-alt" aria-hidden="true"></i> Конкурс рефералов</div>
	<?
	$checkKonkurs_ref = mysql_query( "SELECT * FROM konkurs WHERE type = 1 LIMIT 1" );
	if ( !mysql_num_rows( $checkKonkurs_ref ) ) {
	 ?>
	  <div class="alert alert-info" role="alert">
		Внимание! В данный момент конкурс не активный!
	  </div>
	 <?
	} else {
	  #Задаем количество мест по умолчанию.
	  $number_of_seats_ref = 3;
	 ?>
	  <div class="competition-show">
	    <?
	      $checkKonkursRow_ref = mysql_fetch_array( $checkKonkurs_ref );
	      $month2 = array( 'января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря' );
	    ?>
		<table style="font-size: 14px;">
		  <tr>
			<td colspan="2"><div class="competition-show-name div_centralizator"><?=$checkKonkursRow_ref['name']?></div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2"><div class="competition-show-text div_centralizator"><?=$checkKonkursRow_ref['description']?></div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2"><div class="competition-show-min">Минимальный порог</br> <?=$checkKonkursRow_ref['min_type']?> баллов</div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2">
			  <div class="competition-show-curs">Начисление:</br> 1 балл = 1 приведенный реферал</div>
			  <div class="competition-show-button"><button type="button" class="btn btn-danger btn-sm" onclick="competition.complaints_adm(<?=$checkKonkursRow_ref['id']?>, 'ref');">Сообщить о накрутке</button></div>
			</td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2">
			  <div class="competition-show-date">
			    <div class="">
				  Время проведения:
				  <div class="competition-show-date-icon"></div>
				</div>
			    <div class="competition-show-date-text">
				  <div class="">
				    <i class="fa fa-calendar" aria-hidden="true"></i> с <?=( int ) date ( 'd', $checkKonkursRow_ref['date_start'] ) . ' ' . $month2[( int ) date( 'm', $checkKonkursRow_ref['date_start'] ) - 1] . ' ' . date( 'Y', $checkKonkursRow_ref['date_start'] )?> г.
				  </div>
			      <div class="">
				    <i class="fa fa-calendar" aria-hidden="true"></i> по <?=( int ) date( 'd', $checkKonkursRow_ref['date_end'] ) . ' ' . $month2[( int ) date( 'm', $checkKonkursRow_ref['date_end'] ) - 1] . ' ' . date( 'Y', $checkKonkursRow_ref['date_end'] )?> г.
				  </div>
				</div>
			  </div>
			  <div class="competition-show-prizes">
			    <div class="competition-show-prizes-text">
				  <div class="competition-show-prizes-icon"></div>
				  Призы победителям:
				</div>
				<div class="competition-show-prizes-number">
				  <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_one.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_ref['priz1']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
			      <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_two.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_ref['priz2']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
			      <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_three.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_ref['priz3']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
				  <? if( $checkKonkursRow_ref['priz4'] > 0 ) { 
				    $number_of_seats_ref = 4;
				    ?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_four.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_ref['priz4']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_ref['priz5'] > 0 ) { 
				    $number_of_seats_ref = 5;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_five.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_ref['priz5']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_ref['priz6'] > 0 ) { 
				     $number_of_seats_ref = 6;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_six.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_ref['priz6']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_ref['priz7'] > 0 ) { 
				     $number_of_seats_ref = 7;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_seven.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_ref['priz7']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_ref['priz8'] > 0 ) { 
				    $number_of_seats_ref = 8;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_eight.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_ref['priz8']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_ref['priz9'] > 0 ) { 
				    $number_of_seats_ref = 9;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_nine.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_ref['priz9']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_ref['priz10'] > 0 ) { 
				    $number_of_seats_ref = 10;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_ten.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_ref['priz10']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } ?>
				</div>
			  </div>
			</td>
			<td></td>
		  </tr>
		</table>
	  </div>
	  <table class="standartTable" style="width: 747px; margin: 15px 0 0 15px;">
		<thead>
		  <th style="width: 30px;">Место</th>
		  <th style="text-align: left;">Участник</th>
		  <th style="text-align: center;">Статус</th>
		  <th style="width: 30px;">Баллы</th>
		</thead>
		<?
		  $i2 = 0;
		  $kon2 = mysql_query( "SELECT * FROM konkurs WHERE type = 1 LIMIT 1" );
		  if ( mysql_num_rows( $kon2 ) > 0 ) {
			$kon2Row = mysql_fetch_array( $kon2 );
			$kon2User = mysql_query( "SELECT iduser, summ FROM konkurs_temp WHERE id_konkurs = '" . $kon2Row['id'] . "' and type = '" . $kon2Row['type'] . "' and summ >= '" . $kon2Row['min_type'] . "' ORDER BY summ DESC" );
			while ( $kon2UserRow = mysql_fetch_array( $kon2User ) ) {
			  $i2++;
			  $user2 = mysql_fetch_array( mysql_query( "SELECT id, username, avatar FROM user WHERE id = '" . $kon2UserRow['iduser'] . "' LIMIT 1" ) );
			  if ( $kon2Row['allsumm'] ) {
				if ( $i2 <= $number_of_seats_ref ) {
				  $priz2 = '<div class="competition-priz-text">+' . $kon2Row['priz' . $i2] * $kon2UserRow['summ'] . ' ' . $config['valutaname'] . '</div>';
				} else {
				  $priz2 = '';
				}
			  } else {
				if ( $i2 <= $number_of_seats_ref ) {
				  $priz2 = '<div class="competition-priz-text">участвует, приз: ' . $kon2Row['priz' . $i2] . '' . $config['valutaname'] . '</div>';
				} else {
				  $priz2 = '';
				}
			  }
		      ?>
				<tr>
				  <td style="text-align: center;"><?=$i2?></td>
				  <td style="text-align: left;"><div style="position: relative;">
				    <a href="/id<?=$user2['id']?>">
					  <img src="/temp/avatar/<?=$user2['avatar']?>" class="img-circle competition-avatar-table" width="20" height="20" align="left" />
					</a>
					<?=$user2['username']?></div>
				  </td>
				  <td style="text-align: center; width: 245px; padding: 0 0 0 0;" class=""><?=$priz2?></td>
				  <td style="text-align: center;"><?=$kon2UserRow['summ']?></td>
				</tr>
			  <?
			}
		  }
		?>
	  </table></br>
	 <?
	}
	?>

	<div class="competition-type"><i class="fa fa-list-alt" aria-hidden="true"></i> Конкурс выполнения заданий</div>
	<?
	$checkKonkurs_tasks = mysql_query( "SELECT * FROM konkurs WHERE type = 2 LIMIT 1" );
	if ( !mysql_num_rows( $checkKonkurs_tasks ) ) {
	 ?>
	  <div class="alert alert-info" role="alert">
		Внимание! В данный момент конкурс не активный!
	  </div>
	 <?
	} else {
	  #Задаем количество мест по умолчанию.
	  $number_of_seats_tasks = 3;
	 ?>
	  <div class="competition-show">
	    <?
	      $checkKonkursRow_tasks = mysql_fetch_array( $checkKonkurs_tasks );
	      $month3 = array( 'января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря' );
	    ?>
		<table style="font-size: 14px;">
		  <tr>
			<td colspan="2"><div class="competition-show-name div_centralizator"><?=$checkKonkursRow_tasks['name']?></div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2"><div class="competition-show-text div_centralizator"><?=$checkKonkursRow_tasks['description']?></div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2"><div class="competition-show-min">Минимальный порог</br> <?=$checkKonkursRow_tasks['min_type']?> баллов</div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2">
			  <div class="competition-show-curs">Начисление:</br> 1 балл = 1 выполненное задание</div>
			  <div class="competition-show-button"><button type="button" class="btn btn-danger btn-sm" onclick="competition.complaints_adm(<?=$checkKonkursRow_tasks['id']?>, 'task');">Сообщить о накрутке</button></div>
			</td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2">
			  <div class="competition-show-date">
			    <div class="">
				  Время проведения:
				  <div class="competition-show-date-icon"></div>
				</div>
			    <div class="competition-show-date-text">
				  <div class="">
				    <i class="fa fa-calendar" aria-hidden="true"></i> с <?=( int ) date ( 'd', $checkKonkursRow_tasks['date_start'] ) . ' ' . $month3[( int ) date( 'm', $checkKonkursRow_tasks['date_start'] ) - 1] . ' ' . date( 'Y', $checkKonkursRow_tasks['date_start'] )?> г.
				  </div>
			      <div class="">
				    <i class="fa fa-calendar" aria-hidden="true"></i> по <?=( int ) date( 'd', $checkKonkursRow_tasks['date_end'] ) . ' ' . $month3[( int ) date( 'm', $checkKonkursRow_tasks['date_end'] ) - 1] . ' ' . date( 'Y', $checkKonkursRow_tasks['date_end'] )?> г.
				  </div>
				</div>
			  </div>
			  <div class="competition-show-prizes">
			    <div class="competition-show-prizes-text">
				  <div class="competition-show-prizes-icon"></div>
				  Призы победителям:
				</div>
				<div class="competition-show-prizes-number">
				  <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_one.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks['priz1']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
			      <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_two.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks['priz2']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
			      <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_three.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks['priz3']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
				  <? if( $checkKonkursRow_tasks['priz4'] > 0 ) { 
				    $number_of_seats_tasks = 4;
				    ?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_four.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks['priz4']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks['priz5'] > 0 ) { 
				    $number_of_seats_tasks = 5;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_five.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks['priz5']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks['priz6'] > 0 ) { 
				     $number_of_seats_tasks = 6;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_six.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks['priz6']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks['priz7'] > 0 ) { 
				     $number_of_seats_tasks = 7;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_seven.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks['priz7']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks['priz8'] > 0 ) { 
				    $number_of_seats_tasks = 8;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_eight.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks['priz8']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks['priz9'] > 0 ) { 
				    $number_of_seats_tasks = 9;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_nine.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks['priz9']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks['priz10'] > 0 ) { 
				    $number_of_seats_tasks = 10;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_ten.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks['priz10']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } ?>
				</div>
			  </div>
			</td>
			<td></td>
		  </tr>
		</table>
	  </div>
	  <table class="standartTable" style="width: 747px; margin: 15px 0 0 15px;">
		<thead>
		  <th style="width: 30px;">Место</th>
		  <th style="text-align: left;">Участник</th>
		  <th style="text-align: center;">Статус</th>
		  <th style="width: 30px;">Баллы</th>
		</thead>
		<?
		  $i3 = 0;
		  $kon3 = mysql_query( "SELECT * FROM konkurs WHERE type = 2 LIMIT 1" );
		  if ( mysql_num_rows( $kon3 ) > 0 ) {
			$kon3Row = mysql_fetch_array( $kon3 );
			$kon3User = mysql_query( "SELECT iduser, summ FROM konkurs_temp WHERE id_konkurs = '" . $kon3Row['id'] . "' and type = '" . $kon3Row['type'] . "' and summ >= '" . $kon3Row['min_type'] . "' ORDER BY summ DESC" );
			while ( $kon3UserRow = mysql_fetch_array( $kon3User ) ) {
			  $i3++;
			  $user3 = mysql_fetch_array( mysql_query( "SELECT id, username, avatar FROM user WHERE id = '" . $kon3UserRow['iduser'] . "' LIMIT 1" ) );
			  if ( $kon3Row['allsumm'] ) {
				if ( $i3 <= $number_of_seats_tasks ) {
				  $priz3 = '<div class="competition-priz-text">+' . $kon3Row['priz' . $i3] * $kon3UserRow['summ'] . ' ' . $config['valutaname'] . '</div>';
				} else {
				  $priz3 = '';
				}
			  } else {
				if ( $i3 <= $number_of_seats_tasks ) {
				  $priz3 = '<div class="competition-priz-text">участвует, приз: ' . $kon3Row['priz' . $i3] . '' . $config['valutaname'] . '</div>';
				} else {
				  $priz3 = '';
				}
			  }
		      ?>
				<tr>
				  <td style="text-align: center;"><?=$i3?></td>
				  <td style="text-align: left;"><div style="position: relative;">
				    <a href="/id<?=$user3['id']?>">
					  <img src="/temp/avatar/<?=$user3['avatar']?>" class="img-circle competition-avatar-table" width="20" height="20" align="left" />
					</a>
					<?=$user3['username']?></div>
				  </td>
				  <td style="text-align: center; width: 245px; padding: 0 0 0 0;" class=""><?=$priz3?></td>
				  <td style="text-align: center;"><?=$kon3UserRow['summ']?></td>
				</tr>
			  <?
			}
		  }
		?>
	  </table></br>
	 <?
	}
	?>

	<div class="competition-type"><i class="fa fa-list-alt" aria-hidden="true"></i> Конкурс размещения заданий</div>
	<?
	$checkKonkurs_tasks_adv = mysql_query( "SELECT * FROM konkurs WHERE type = 3 LIMIT 1" );
	if ( !mysql_num_rows( $checkKonkurs_tasks_adv ) ) {
	 ?>
	  <div class="alert alert-info" role="alert">
		Внимание! В данный момент конкурс не активный!
	  </div>
	 <?
	} else {
	  #Задаем количество мест по умолчанию.
	  $number_of_seats_tasks_adv = 3;
	 ?>
	  <div class="competition-show">
	    <?
	      $checkKonkursRow_tasks_adv = mysql_fetch_array( $checkKonkurs_tasks_adv );
	      $month4 = array( 'января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря' );
	    ?>
		<table style="font-size: 14px;">
		  <tr>
			<td colspan="2"><div class="competition-show-name div_centralizator"><?=$checkKonkursRow_tasks_adv['name']?></div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2"><div class="competition-show-text div_centralizator"><?=$checkKonkursRow_tasks_adv['description']?></div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2"><div class="competition-show-min">Минимальный порог</br> <?=$checkKonkursRow_tasks_adv['min_type']?> баллов</div></td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2">
			  <div class="competition-show-curs">Начисление:</br> 1 балл = каждый 1 <?=$config['valutaname']?> потраченный на оплату выполнения задания</div>
			  <div class="competition-show-button"><button type="button" class="btn btn-danger btn-sm" onclick="competition.complaints_adm(<?=$checkKonkursRow_tasks_adv['id']?>, 'task_adv');">Сообщить о накрутке</button></div>
			</td>
			<td></td>
		  </tr>
		  <tr>
			<td colspan="2">
			  <div class="competition-show-date-tsk">
			    <div class="">
				  Время проведения:
				  <div class="competition-show-date-icon"></div>
				</div>
			    <div class="competition-show-date-text">
				  <div class="">
				    <i class="fa fa-calendar" aria-hidden="true"></i> с <?=( int ) date ( 'd', $checkKonkursRow_tasks_adv['date_start'] ) . ' ' . $month4[( int ) date( 'm', $checkKonkursRow_tasks_adv['date_start'] ) - 1] . ' ' . date( 'Y', $checkKonkursRow_tasks_adv['date_start'] )?> г.
				  </div>
			      <div class="">
				    <i class="fa fa-calendar" aria-hidden="true"></i> по <?=( int ) date( 'd', $checkKonkursRow_tasks_adv['date_end'] ) . ' ' . $month4[( int ) date( 'm', $checkKonkursRow_tasks_adv['date_end'] ) - 1] . ' ' . date( 'Y', $checkKonkursRow_tasks_adv['date_end'] )?> г.
				  </div>
				</div>
			  </div>
			  <div class="competition-show-prizes-tsk">
			    <div class="competition-show-prizes-text">
				  <div class="competition-show-prizes-icon"></div>
				  Призы победителям:
				</div>
				<div class="competition-show-prizes-number">
				  <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_one.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks_adv['priz1']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
			      <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_two.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks_adv['priz2']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
			      <div class="competition-prizes-number-text">
				    <img src="/theme/images/competition_three.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks_adv['priz3']?> <?=$config['valutaname']?> на рабочий счет
				  </div>
				  <? if( $checkKonkursRow_tasks_adv['priz4'] > 0 ) { 
				    $number_of_seats_tasks_adv = 4;
				    ?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_four.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks_adv['priz4']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks_adv['priz5'] > 0 ) { 
				    $number_of_seats_tasks_adv = 5;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_five.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks_adv['priz5']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks_adv['priz6'] > 0 ) { 
				     $number_of_seats_tasks_adv = 6;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_six.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks_adv['priz6']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks_adv['priz7'] > 0 ) { 
				     $number_of_seats_tasks_adv = 7;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_seven.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks_adv['priz7']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks_adv['priz8'] > 0 ) { 
				    $number_of_seats_tasks_adv = 8;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_eight.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks_adv['priz8']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks_adv['priz9'] > 0 ) { 
				    $number_of_seats_tasks_adv = 9;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_nine.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks_adv['priz9']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } if( $checkKonkursRow_tasks_adv['priz10'] > 0 ) { 
				    $number_of_seats_tasks_adv = 10;
					?>
			        <div class="competition-prizes-number-text">
				      <img src="/theme/images/competition_ten.png" class="competition-prizes-number-img"/> место: <?=$checkKonkursRow_tasks_adv['priz10']?> <?=$config['valutaname']?> на рабочий счет
				    </div>
				  <? } ?>
				</div>
			  </div>
			</td>
			<td></td>
		  </tr>
		</table>
	  </div>
	  <table class="standartTable" style="width: 747px; margin: 15px 0 0 15px;">
		<thead>
		  <th style="width: 30px;">Место</th>
		  <th style="text-align: left;">Участник</th>
		  <th style="text-align: center;">Статус</th>
		  <th style="width: 30px;">Баллы</th>
		</thead>
		<?
		  $i4 = 0;
		  $kon4 = mysql_query( "SELECT * FROM konkurs WHERE type = 3 LIMIT 1" );
		  if ( mysql_num_rows( $kon4 ) > 0 ) {
			$kon4Row = mysql_fetch_array( $kon4 );
			$kon4User = mysql_query( "SELECT iduser, summ FROM konkurs_temp WHERE id_konkurs = '" . $kon4Row['id'] . "' and type = '" . $kon4Row['type'] . "' and summ >= '" . $kon4Row['min_type'] . "' ORDER BY summ DESC" );
			while ( $kon4UserRow = mysql_fetch_array( $kon4User ) ) {
			  $i4++;
			  $user4 = mysql_fetch_array( mysql_query( "SELECT id, username, avatar FROM user WHERE id = '" . $kon4UserRow['iduser'] . "' LIMIT 1" ) );
			  if ( $kon4Row['allsumm'] ) {
				if ( $i4 <= $number_of_seats_tasks_adv ) {
				  $priz3 = '<div class="competition-priz-text">+' . $kon4Row['priz' . $i4] * $kon4UserRow['summ'] . ' ' . $config['valutaname'] . '</div>';
				} else {
				  $priz3 = '';
				}
			  } else {
				if ( $i4 <= $number_of_seats_tasks_adv ) {
				  $priz3 = '<div class="competition-priz-text">участвует, приз: ' . $kon4Row['priz' . $i4] . '' . $config['valutaname'] . '</div>';
				} else {
				  $priz3 = '';
				}
			  }
		      ?>
				<tr>
				  <td style="text-align: center;"><?=$i4?></td>
				  <td style="text-align: left;"><div style="position: relative;">
				    <a href="/id<?=$user4['id']?>">
					  <img src="/temp/avatar/<?=$user4['avatar']?>" class="img-circle competition-avatar-table" width="20" height="20" align="left" />
					</a>
					<?=$user4['username']?></div>
				  </td>
				  <td style="text-align: center; width: 245px; padding: 0 0 0 0;" class=""><?=$priz3?></td>
				  <td style="text-align: center;"><?=$kon4UserRow['summ']?></td>
				</tr>
			  <?
			}
		  }
		?>
	  </table></br>
	 <?
	}
	?>

  </article>
</div>