<?
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';
    include_once ROOT_DIR . '/engine/classes/bbcode.class.php';
} else {
    if ( !defined( 'MISOFT' ) ) { exit(); }
}

if ( !isset( $_SESSION['iduser'] ) ) {
    echo '<div style="margin-left: -10px;" class="alert alert-info alert-dismissible fade in" role="alert">
			<button type="button" class="close" data-dismiss="alert" aria-label="Close">
				<span aria-hidden="true">&times;</span>
			</button>
			<h5 class="alert-heading"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Внимание!</h5>
			<p style="font-size: 14px;">Вы не авторизованы. Доступ к этой странице разрешен только авторизованным пользователям. <br>Пожалуйста, воспользуйтесь формой авторизации.</p>
			<p style="font-size: 14px;" class="m-b-0">Для перехода в форму авторизации нажмите <a class="a_link" href="/login" >вход</a>.</p>
		  </div>';
} else {
    
	if ( substr( $_SERVER['REQUEST_URI'], 0, 11 ) == '/tasks_work' OR substr( $_SERVER['REQUEST_URI'], 0, 14 ) == '/tasks_work&p=') {
		#Запрос подсчета количества страниц (являеться аналогом центрального циклового запроса, за исключением параметров сортировки)
		$tasks_page = mysql_fetch_array( mysql_query( "SELECT COUNT(id) as count FROM tasks WHERE id IN(SELECT ident FROM tasks_temp WHERE iduser = '" . $_SESSION['iduser'] . "' and status in (0,3))" ) );
		$kolvo = 15;
		$all = $tasks_page['count'];
		$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; }
		
		?>
		<div id="modal_windows_open"></div>
		
		<? include_once ROOT_DIR . '/modules/panel_manager/section_earnings.php'; ?>
		
		<div class="content_bar">
			<article class="postBox">
			
				<? include_once ROOT_DIR . '/modules/tasks/menu.php'; ?>
			
				<script type="text/javascript">
				  $(document).ready(function(){
					$('.icon-vip-task').tipTip({defaultPosition:'right'});
					$('.workcomp').tipTip({defaultPosition:'right'});
					$('.cursor-help').tipTip({defaultPosition:'right'});
					$('.advertiser-task-show').tipTip({defaultPosition:'right'});
				  });	
				</script>
				
				<table class="work-serf">
					<tbody>
						<?
						$sh_tasks = mysql_query( "SELECT * FROM tasks WHERE id IN(SELECT ident FROM tasks_temp WHERE iduser = '" . $_SESSION['iduser'] . "' and status in (0,3)) ORDER BY date DESC LIMIT $start,$kolvo" ) or die( mysql_error() );
						
						if ( mysql_num_rows( $sh_tasks ) > 0 ) {
							while ( $sh_tasks_row = mysql_fetch_array( $sh_tasks ) ) {
								
								#Иконка задания на которое нажали
								$img_tasks_footstep = '<img src="/theme/images/footstep_adv.png" width="32" height="32" alt="" class="icon-vip-task" title="Просмотренное задание" id="icon_24h_task' . $sh_tasks_row['id'] . '" />';
								
								#Иконка задания
								$img_tasks = '<div title="Обычное задание" id="icon_standart_task' . $sh_tasks_row['id'] . '" ><i class="fa fa-briefcase color-green" ></i></div>';
								
								#Проверка на многоразовое задание
								if ( $sh_tasks_row['many'] == 1 ) {
									$img_tasks = '<img src="/theme/images/24-hours.png" width="32" height="32" alt="" class="icon-vip-task" title="Задание многоразовое" id="icon_24h_task' . $sh_tasks_row['id'] . '" />';
								} else
								
								#Проверка V.I.P
								if ( $sh_tasks_row['vip'] == 1 ) {
									$img_tasks = '<img src="/theme/images/crown.png" width="32" height="32" alt="" class="icon-vip-task" title="Задание V.I.P категории" id="icon_vip_task' . $sh_tasks_row['id'] . '" />';
								}
								
								#Автор задания
								$task_user_avtor = mysql_fetch_array( mysql_query( "SELECT username, id FROM user WHERE id = '" . $sh_tasks_row['iduser'] . "' LIMIT 1" ) );
								
								#Категория задания
								if ($sh_tasks_row['ShownKategories'] == 1 ) { $kategories_task_text = 'Только регистрация'; } else
								if ($sh_tasks_row['ShownKategories'] == 2 ) { $kategories_task_text = 'Только клики'; } else
								if ($sh_tasks_row['ShownKategories'] == 3 ) { $kategories_task_text = 'Регистрация с активностью'; } else
								if ($sh_tasks_row['ShownKategories'] == 4 ) { $kategories_task_text = 'Приглашение в рефералы'; } else
								if ($sh_tasks_row['ShownKategories'] == 5 ) { $kategories_task_text = 'Социальные сети'; } else
								if ($sh_tasks_row['ShownKategories'] == 6 ) { $kategories_task_text = 'YouTube'; } else
								if ($sh_tasks_row['ShownKategories'] == 7 ) { $kategories_task_text = 'Постинг в форумы и/или блоги'; } else
								if ($sh_tasks_row['ShownKategories'] == 8 ) { $kategories_task_text = 'Написать статью или пресс-релиз'; } else
								if ($sh_tasks_row['ShownKategories'] == 9 ) { $kategories_task_text = 'Отзыв/проголосовать'; } else
								if ($sh_tasks_row['ShownKategories'] == 10 ) { $kategories_task_text = 'Forex'; } else
								if ($sh_tasks_row['ShownKategories'] == 11 ) { $kategories_task_text = 'Bitcoin/Litecoin/Dogecoin'; } else
								if ($sh_tasks_row['ShownKategories'] == 12 ) { $kategories_task_text = 'Играть в игры'; } else
								if ($sh_tasks_row['ShownKategories'] == 13 ) { $kategories_task_text = 'Инвестировать'; } else
								if ($sh_tasks_row['ShownKategories'] == 14 ) { $kategories_task_text = 'Мобильные приложения'; } else
								if ($sh_tasks_row['ShownKategories'] == 15 ) { $kategories_task_text = 'Бонусы'; } else
								if ($sh_tasks_row['ShownKategories'] == 16 ) { $kategories_task_text = 'Прочее'; }
								
								#Обрезаем ссылку
								$task_cropped_link = crop_the_link($sh_tasks_row['url'], '50');

								?>
								  <script type="text/javascript">
									$(document).ready(function(){
									  $('#icon_standart_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
									  $('#icon_24h_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
									  $('#icon_vip_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
									});
									function footstep(a) {
									  $('#footstep_'+ a +'_off').fadeOut(5);
									  $('#footstep_'+ a +'_on').fadeIn(3);
									}
								  </script>
								  <tr id="d<?=$sh_tasks_row['id']?>">
									<td class="normal" width="40" valign="top" >
									  <div class="img-icon-task" id="footstep_<?=$sh_tasks_row['id']?>_off">
										<?=$img_tasks?>
									  </div>
									  <div class="img-icon-task" id="footstep_<?=$sh_tasks_row['id']?>_on" style="display: none;">
										<?=$img_tasks_footstep?>
									  </div>
									</td>
									<td class="normalm" valign="top" >
									  <div class="info-show-task">
										<a href="/tasksview=<?=$sh_tasks_row['id']?>" target="_blank" onclick="footstep(<?=$sh_tasks_row['id']?>);"><?=$sh_tasks_row['title']?></a><br>
										<span class="desctext"><?=$task_cropped_link?></span> 
										<span class="desctext">ID:<?=$sh_tasks_row['id']?> - <?=$kategories_task_text?></span>
									  </div>
									</td>
									<td class="normal" style="text-align: center;" valign="center" nowrap="nowrap" >
									  <div class="advertiser-task-show" title="Рекламодатель: <?=$task_user_avtor['username']?>">
										<a href="/id<?=$task_user_avtor['id']?>"><i class="fa fa-bullhorn advertiser-task-show_link" aria-hidden="true"></i></a>
									  </div>
									  <span class="clickprice color-grey"><?=moneyraund( $sh_tasks_row['price'], 3 )?> <?=$config['valutaname']?> </span><br>
									</td>
									<td class="normal" style="text-align: center; width: 15%;">
									  <span title="Одобрено заданий" class="color-green cursor-help"><?=$sh_tasks_row['t_goods']?></span> - 
									  <span title="Отклонено заданий" class="color-red cursor-help"><?=$sh_tasks_row['t_bad']?></span> - 
									  <span title="На проверке заданий" class="color-grey cursor-help"><?=$sh_tasks_row['t_wait']?></span>
									  
									</td>
									<td class="normal" style="width: 6.6%;" >
									  <div class="doing-show-task">
										<a onclick="adv_ell.complaints(<?=$sh_tasks_row['id']?>, 'task');" class="complaints_adv"  target="_blank">
										  <i class="glyphicon glyphicon-ban-circle workcomp" aria-hidden="true" title="Пожаловаться на рекламу" ></i>
										</a>
									  </div>
									</td>
								  </tr>
								<?
							}
						} else {
						  ?>
							<tr>
							  <td colspan="2">
								<div class="inquiry-search-task"><i class="fa fa-info-circle" aria-hidden="true"></i> В данный момент этот список пуст.</div>
								</td>
							</tr>
						  <?
						}
						?>
					</tbody>
				</table>
				<div class="navigation-page-task"><? echo navigation( 15, ( int ) $_GET['page'], $tasks_page['count'], 'tasks_work&p=' ); ?></div>
				<div class="banner_gorizontal banner_gorizontal_fix" style="margin-top: 31px;"><? include_once ROOT_DIR . '/modules/banner468x60/rotator.php';?></div>
			
			</article>
		</div>
		<?
	} else
	if ( substr( $_SERVER['REQUEST_URI'], 0, 11 ) == '/tasks_wait' OR substr( $_SERVER['REQUEST_URI'], 0, 14 ) == '/tasks_wait&p=') {
		#Запрос подсчета количества страниц (являеться аналогом центрального циклового запроса, за исключением параметров сортировки)
		$tasks_page = mysql_fetch_array( mysql_query( "SELECT COUNT(id) as count FROM tasks WHERE id IN(SELECT ident FROM tasks_temp WHERE iduser = '" . $_SESSION['iduser'] . "' and status in (4))" ) );
		$kolvo = 15;
		$all = $tasks_page['count'];
		$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; }
		
		?>
		<div id="modal_windows_open"></div>
		
		<? include_once ROOT_DIR . '/modules/panel_manager/section_earnings.php'; ?>
		
		<div class="content_bar">
			<article class="postBox">
			
				<? include_once ROOT_DIR . '/modules/tasks/menu.php'; ?>
			
				<script type="text/javascript">
				  $(document).ready(function(){
					$('.icon-vip-task').tipTip({defaultPosition:'right'});
					$('.workcomp').tipTip({defaultPosition:'right'});
					$('.cursor-help').tipTip({defaultPosition:'right'});
					$('.advertiser-task-show').tipTip({defaultPosition:'right'});
				  });	
				</script>
				
				<table class="work-serf">
					<tbody>
						<?
						$sh_tasks = mysql_query( "SELECT * FROM tasks WHERE id IN(SELECT ident FROM tasks_temp WHERE iduser = '" . $_SESSION['iduser'] . "' and status in (4)) ORDER BY date DESC LIMIT $start,$kolvo" ) or die( mysql_error() );
						
						if ( mysql_num_rows( $sh_tasks ) > 0 ) {
							while ( $sh_tasks_row = mysql_fetch_array( $sh_tasks ) ) {
								#Иконка задания на которое нажали
								$img_tasks_footstep = '<img src="/theme/images/footstep_adv.png" width="32" height="32" alt="" class="icon-vip-task" title="Просмотренное задание" id="icon_24h_task' . $sh_tasks_row['id'] . '" />';
								
								#Иконка задания
								$img_tasks = '<div title="Обычное задание" id="icon_standart_task' . $sh_tasks_row['id'] . '" ><i class="fa fa-briefcase color-green" ></i></div>';
								
								#Проверка на многоразовое задание
								if ( $sh_tasks_row['many'] == 1 ) {
									$img_tasks = '<img src="/theme/images/24-hours.png" width="32" height="32" alt="" class="icon-vip-task" title="Задание многоразовое" id="icon_24h_task' . $sh_tasks_row['id'] . '" />';
								} else
								
								#Проверка V.I.P
								if ( $sh_tasks_row['vip'] == 1 ) {
									$img_tasks = '<img src="/theme/images/crown.png" width="32" height="32" alt="" class="icon-vip-task" title="Задание V.I.P категории" id="icon_vip_task' . $sh_tasks_row['id'] . '" />';
								}
								
								#Автор задания
								$task_user_avtor = mysql_fetch_array( mysql_query( "SELECT username, id FROM user WHERE id = '" . $sh_tasks_row['iduser'] . "' LIMIT 1" ) );
								
								#Категория задания
								if ($sh_tasks_row['ShownKategories'] == 1 ) { $kategories_task_text = 'Только регистрация'; } else
								if ($sh_tasks_row['ShownKategories'] == 2 ) { $kategories_task_text = 'Только клики'; } else
								if ($sh_tasks_row['ShownKategories'] == 3 ) { $kategories_task_text = 'Регистрация с активностью'; } else
								if ($sh_tasks_row['ShownKategories'] == 4 ) { $kategories_task_text = 'Приглашение в рефералы'; } else
								if ($sh_tasks_row['ShownKategories'] == 5 ) { $kategories_task_text = 'Социальные сети'; } else
								if ($sh_tasks_row['ShownKategories'] == 6 ) { $kategories_task_text = 'YouTube'; } else
								if ($sh_tasks_row['ShownKategories'] == 7 ) { $kategories_task_text = 'Постинг в форумы и/или блоги'; } else
								if ($sh_tasks_row['ShownKategories'] == 8 ) { $kategories_task_text = 'Написать статью или пресс-релиз'; } else
								if ($sh_tasks_row['ShownKategories'] == 9 ) { $kategories_task_text = 'Отзыв/проголосовать'; } else
								if ($sh_tasks_row['ShownKategories'] == 10 ) { $kategories_task_text = 'Forex'; } else
								if ($sh_tasks_row['ShownKategories'] == 11 ) { $kategories_task_text = 'Bitcoin/Litecoin/Dogecoin'; } else
								if ($sh_tasks_row['ShownKategories'] == 12 ) { $kategories_task_text = 'Играть в игры'; } else
								if ($sh_tasks_row['ShownKategories'] == 13 ) { $kategories_task_text = 'Инвестировать'; } else
								if ($sh_tasks_row['ShownKategories'] == 14 ) { $kategories_task_text = 'Мобильные приложения'; } else
								if ($sh_tasks_row['ShownKategories'] == 15 ) { $kategories_task_text = 'Бонусы'; } else
								if ($sh_tasks_row['ShownKategories'] == 16 ) { $kategories_task_text = 'Прочее'; }
								
								#Обрезаем ссылку
								$task_cropped_link = crop_the_link($sh_tasks_row['url'], '50');
											
								?>
								  <script type="text/javascript">
									$(document).ready(function(){
									  $('#icon_standart_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
									  $('#icon_24h_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
									  $('#icon_vip_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
									});
									function footstep(a) {
									  $('#footstep_'+ a +'_off').fadeOut(5);
									  $('#footstep_'+ a +'_on').fadeIn(3);
									}
								  </script>
								  <tr id="d<?=$sh_tasks_row['id']?>">
									<td class="normal" width="40" valign="top" >
									  <div class="img-icon-task" id="footstep_<?=$sh_tasks_row['id']?>_off">
										<?=$img_tasks?>
									  </div>
									  <div class="img-icon-task" id="footstep_<?=$sh_tasks_row['id']?>_on" style="display: none;">
										<?=$img_tasks_footstep?>
									  </div>
									</td>
									<td class="normalm" valign="top" >
									  <div class="info-show-task">
										<a href="/tasksview=<?=$sh_tasks_row['id']?>" target="_blank" onclick="footstep(<?=$sh_tasks_row['id']?>);"><?=$sh_tasks_row['title']?></a><br>
										<span class="desctext"><?=$task_cropped_link?></span> 
										<span class="desctext">ID:<?=$sh_tasks_row['id']?> - <?=$kategories_task_text?></span>
									  </div>
									</td>
									<td class="normal" style="text-align: center;" valign="center" nowrap="nowrap" >
									  <div class="advertiser-task-show" title="Рекламодатель: <?=$task_user_avtor['username']?>">
										<a href="/id<?=$task_user_avtor['id']?>"><i class="fa fa-bullhorn advertiser-task-show_link" aria-hidden="true"></i></a>
									  </div>
									  <span class="clickprice color-grey"><?=moneyraund( $sh_tasks_row['price'], 3 )?> <?=$config['valutaname']?> </span><br>
									</td>
									<td class="normal" style="text-align: center; width: 15%;">
									  <span title="Одобрено заданий" class="color-green cursor-help"><?=$sh_tasks_row['t_goods']?></span> - 
									  <span title="Отклонено заданий" class="color-red cursor-help"><?=$sh_tasks_row['t_bad']?></span> - 
									  <span title="На проверке заданий" class="color-grey cursor-help"><?=$sh_tasks_row['t_wait']?></span>
									  
									</td>
									<td class="normal" style="width: 6.6%;" >
									  <div class="doing-show-task">
										<a onclick="adv_ell.complaints(<?=$sh_tasks_row['id']?>, 'task');" class="complaints_adv"  target="_blank">
										  <i class="glyphicon glyphicon-ban-circle workcomp" aria-hidden="true" title="Пожаловаться на рекламу" ></i>
										</a>
									  </div>
									</td>
								  </tr>
								<?
							}
						} else {
						  ?>
							<tr>
							  <td colspan="2">
								<div class="inquiry-search-task"><i class="fa fa-info-circle" aria-hidden="true"></i> В данный момент этот список пуст.</div>
								</td>
							</tr>
						  <?
						}
						?>
					</tbody>
				</table>
				<div class="navigation-page-task"><? echo navigation( 15, ( int ) $_GET['page'], $tasks_page['count'], 'tasks_wait&p=' ); ?></div>
				<div class="banner_gorizontal banner_gorizontal_fix" style="margin-top: 31px;"><? include_once ROOT_DIR . '/modules/banner468x60/rotator.php';?></div>
			
			</article>
		</div>
		<?
	} else
	if ( substr( $_SERVER['REQUEST_URI'], 0, 8 ) == '/tasksok' OR substr( $_SERVER['REQUEST_URI'], 0, 11 ) == '/tasksok&p=' ) {
		
		#Запрос подсчета количества страниц (являеться аналогом центрального циклового запроса, за исключением параметров сортировки)
		$tasks_page = mysql_fetch_array( mysql_query( "SELECT COUNT(id) as count FROM tasks WHERE id IN(SELECT ident FROM tasks_temp WHERE iduser = '" . $_SESSION['iduser'] . "' and status in (1,2))" ) );
		$kolvo = 15;
		$all = $tasks_page['count'];
		$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; }
		
		?>
		<div id="modal_windows_open"></div>
		
		<? include_once ROOT_DIR . '/modules/panel_manager/section_earnings.php'; ?>
		
		<div class="content_bar">
			<article class="postBox">
			
				<? include_once ROOT_DIR . '/modules/tasks/menu.php'; ?>
			
				<script type="text/javascript">
				  $(document).ready(function(){
					$('.icon-vip-task').tipTip({defaultPosition:'right'}); 
					$('.workcomp').tipTip({defaultPosition:'right'});
					$('.cursor-help').tipTip({defaultPosition:'right'});
					$('.advertiser-task-show').tipTip({defaultPosition:'right'});
				  });	
				</script>
				
				<table class="work-serf">
					<tbody>
					  <?
						$sh_tasks = mysql_query( "SELECT * FROM tasks WHERE id IN(SELECT ident FROM tasks_temp WHERE iduser = '" . $_SESSION['iduser'] . "' and status in (1,2)) ORDER BY date DESC LIMIT $start,$kolvo" ) or die( mysql_error() );
						
						if ( mysql_num_rows( $sh_tasks ) > 0 ) {
						
							while ( $sh_tasks_row = mysql_fetch_array( $sh_tasks ) ) {
								#Иконка задания на которое нажали
								$img_tasks_footstep = '<img src="/theme/images/footstep_adv.png" width="32" height="32" alt="" class="icon-vip-task" title="Просмотренное задание" id="icon_24h_task' . $sh_tasks_row['id'] . '" />';
								
								#Иконка задания
								$img_tasks = '<div title="Обычное задание" id="icon_standart_task' . $sh_tasks_row['id'] . '" ><i class="fa fa-briefcase color-green" ></i></div>';
								
								#Проверка на многоразовое задание
								if ( $sh_tasks_row['many'] == 1 ) {
									$img_tasks = '<img src="/theme/images/24-hours.png" width="32" height="32" alt="" class="icon-vip-task" title="Задание многоразовое" id="icon_24h_task' . $sh_tasks_row['id'] . '" />';
								} else
								
								#Проверка V.I.P
								if ( $sh_tasks_row['vip'] == 1 ) {
									$img_tasks = '<img src="/theme/images/crown.png" width="32" height="32" alt="" class="icon-vip-task" title="Задание V.I.P категории" id="icon_vip_task' . $sh_tasks_row['id'] . '" />';
								}
								
								#Автор задания
								$task_user_avtor = mysql_fetch_array( mysql_query( "SELECT username, id FROM user WHERE id = '" . $sh_tasks_row['iduser'] . "' LIMIT 1" ) );
								
								$get_task_com = mysql_query( "SELECT id FROM tasks_comment WHERE ident = '" . $sh_tasks_row['id'] . "' and iduser = '" . $_SESSION['iduser'] . "'" );
								if ( mysql_num_rows( $get_task_com ) > 0 ) {
									$all_comm = mysql_fetch_array( mysql_query( "SELECT COUNT(id) as count FROM tasks_comment WHERE ident = '" . $sh_tasks_row['id'] . "'" ) );
									$btn_comms = '<span class="task_comm" onclick="tasks.ShowComment(' . $sh_tasks_row['id'] . ');">' . $all_comm['count'] . '</span>';
								} else {
									$btn_comms = '<a href="#" class="a_box" onclick="addtaskcomm(' . $sh_tasks_row['id'] . ');return false">Оставить комментарий</a>';
								}
								
								#Категория задания
								if ($sh_tasks_row['ShownKategories'] == 1 ) { $kategories_task_text = 'Только регистрация'; } else
								if ($sh_tasks_row['ShownKategories'] == 2 ) { $kategories_task_text = 'Только клики'; } else
								if ($sh_tasks_row['ShownKategories'] == 3 ) { $kategories_task_text = 'Регистрация с активностью'; } else
								if ($sh_tasks_row['ShownKategories'] == 4 ) { $kategories_task_text = 'Приглашение в рефералы'; } else
								if ($sh_tasks_row['ShownKategories'] == 5 ) { $kategories_task_text = 'Социальные сети'; } else
								if ($sh_tasks_row['ShownKategories'] == 6 ) { $kategories_task_text = 'YouTube'; } else
								if ($sh_tasks_row['ShownKategories'] == 7 ) { $kategories_task_text = 'Постинг в форумы и/или блоги'; } else
								if ($sh_tasks_row['ShownKategories'] == 8 ) { $kategories_task_text = 'Написать статью или пресс-релиз'; } else
								if ($sh_tasks_row['ShownKategories'] == 9 ) { $kategories_task_text = 'Отзыв/проголосовать'; } else
								if ($sh_tasks_row['ShownKategories'] == 10 ) { $kategories_task_text = 'Forex'; } else
								if ($sh_tasks_row['ShownKategories'] == 11 ) { $kategories_task_text = 'Bitcoin/Litecoin/Dogecoin'; } else
								if ($sh_tasks_row['ShownKategories'] == 12 ) { $kategories_task_text = 'Играть в игры'; } else
								if ($sh_tasks_row['ShownKategories'] == 13 ) { $kategories_task_text = 'Инвестировать'; } else
								if ($sh_tasks_row['ShownKategories'] == 14 ) { $kategories_task_text = 'Мобильные приложения'; } else
								if ($sh_tasks_row['ShownKategories'] == 15 ) { $kategories_task_text = 'Бонусы'; } else
								if ($sh_tasks_row['ShownKategories'] == 16 ) { $kategories_task_text = 'Прочее'; }
								
								#Обрезаем ссылку
								$task_cropped_link = crop_the_link($sh_tasks_row['url'], '50');

								?>
								  <script type="text/javascript">
									$(document).ready(function(){
									  $('#icon_standart_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
									  $('#icon_24h_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
									  $('#icon_vip_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
									});
									function footstep(a) {
									  $('#footstep_'+ a +'_off').fadeOut(5);
									  $('#footstep_'+ a +'_on').fadeIn(3);
									}
								  </script>
								  <tr id="d<?=$sh_tasks_row['id']?>">
									<td class="normal" width="40" valign="top" >
									  <div class="img-icon-task" id="footstep_<?=$sh_tasks_row['id']?>_off">
										<?=$img_tasks?>
									  </div>
									  <div class="img-icon-task" id="footstep_<?=$sh_tasks_row['id']?>_on" style="display: none;">
										<?=$img_tasks_footstep?>
									  </div>
									</td>
									<td class="normalm" valign="top" >
									  <div class="info-show-task">
										<a href="/tasksview=<?=$sh_tasks_row['id']?>" target="_blank" onclick="footstep(<?=$sh_tasks_row['id']?>);"><?=$sh_tasks_row['title']?></a><br>
										<span class="desctext"><?=$task_cropped_link?></span> 
										<span class="desctext">ID:<?=$sh_tasks_row['id']?> - <?=$kategories_task_text?></span>
									  </div>
									</td>
									<td class="normal" style="text-align: center;" valign="center" nowrap="nowrap" >
									  <div class="advertiser-task-show" title="Рекламодатель: <?=$task_user_avtor['username']?>">
										<a href="/id<?=$task_user_avtor['id']?>"><i class="fa fa-bullhorn advertiser-task-show_link" aria-hidden="true"></i></a>
									  </div>
									  <span class="clickprice color-grey"><?=moneyraund( $sh_tasks_row['price'], 3 )?> <?=$config['valutaname']?> </span><br>
									</td>
									<td class="normal" style="text-align: center; width: 15%;">
									  <span title="Одобрено заданий" class="color-green cursor-help"><?=$sh_tasks_row['t_goods']?></span> - 
									  <span title="Отклонено заданий" class="color-red cursor-help"><?=$sh_tasks_row['t_bad']?></span> - 
									  <span title="На проверке заданий" class="color-grey cursor-help"><?=$sh_tasks_row['t_wait']?></span>
									  
									</td>
									<td class="normal" style="width: 6.6%;" >
									  <div class="doing-show-task">
										<a onclick="adv_ell.complaints(<?=$sh_tasks_row['id']?>, 'task');" class="complaints_adv"  target="_blank">
										  <i class="glyphicon glyphicon-ban-circle workcomp" aria-hidden="true" title="Пожаловаться на рекламу" ></i>
										</a>
									  </div>
									</td>
								  </tr>
								<?
							} 
						} else {
						  ?>
							<tr>
							  <td colspan="2">
								<div class="inquiry-search-task"><i class="fa fa-info-circle" aria-hidden="true"></i> В данный момент этот список пуст.</div>
								</td>
							</tr>
						  <?
						}
					  ?>
					</tbody>
				</table>
				<div class="navigation-page-task"><? echo navigation( 15, ( int ) $_GET['page'], $tasks_page['count'], 'tasksok&p=' ); ?></div>
				<div class="banner_gorizontal banner_gorizontal_fix" style="margin-top: 31px;"><? include_once ROOT_DIR . '/modules/banner468x60/rotator.php';?></div>
			
			</article>
		</div>
		<?
	} else
	if ( substr( $_SERVER['REQUEST_URI'], 0, 15 ) == '/selected_tasks' OR substr( $_SERVER['REQUEST_URI'], 0, 18 ) == '/selected_tasks&p=' ) {	
		
		#Запрос подсчета количества страниц (являеться аналогом центрального циклового запроса, за исключением параметров сортировки)
		$tasks_page = mysql_fetch_array( mysql_query( "SELECT COUNT(id) as count FROM tasks t1 WHERE many = 1 and EXISTS(SELECT ident, iduser FROM tasks_favorites t2 WHERE iduser = '" . $_SESSION['iduser'] . "' and t1.id = t2.ident)" ) );
		$kolvo = 15;
		$all = $tasks_page['count'];
		$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; }
		
		?>
		<div id="modal_windows_open"></div>
		
		<? include_once ROOT_DIR . '/modules/panel_manager/section_earnings.php'; ?>
		
		<div class="content_bar">
			<article class="postBox">
			
				<? include_once ROOT_DIR . '/modules/tasks/menu.php'; ?>
			
				<script type="text/javascript">
				  $(document).ready(function(){
					$('.workcomp').tipTip({defaultPosition:'right'});
					$('.cursor-help').tipTip({defaultPosition:'right'});
					$('.advertiser-task-show').tipTip({defaultPosition:'right'});
					$('.icon-vip-task').tipTip({defaultPosition:'right'});
				  });	
				</script>
				
				<table class="work-serf">
					<tbody>
					  <?
						$sh_tasks = mysql_query( "SELECT * FROM tasks t1 WHERE many = 1 and EXISTS(SELECT ident, iduser FROM tasks_favorites t2 WHERE iduser = '" . $_SESSION['iduser'] . "' and t1.id = t2.ident) ORDER BY date DESC  LIMIT $start,$kolvo" ) or die( mysql_error() );
						
						if ( mysql_num_rows( $sh_tasks ) > 0 ) {
							while ( $sh_tasks_row = mysql_fetch_array( $sh_tasks ) ) {
								#Иконка задания на которое нажали
								$img_tasks_footstep = '<img src="/theme/images/footstep_adv.png" width="32" height="32" alt="" class="icon-vip-task" title="Просмотренное задание" id="icon_24h_task' . $sh_tasks_row['id'] . '" />';
								
								#Иконка задания
								$img_tasks = '<div title="Обычное задание" id="icon_standart_task' . $sh_tasks_row['id'] . '" ><i class="fa fa-briefcase color-green" ></i></div>';
								
								#Проверка на многоразовое задание
								if ( $sh_tasks_row['many'] == 1 ) {
									$img_tasks = '<img src="/theme/images/24-hours.png" width="32" height="32" alt="" class="icon-vip-task" title="Задание многоразовое" id="icon_24h_task' . $sh_tasks_row['id'] . '" />';
								} else
								
								#Проверка V.I.P
								if ( $sh_tasks_row['vip'] == 1 ) {
									$img_tasks = '<img src="/theme/images/crown.png" width="32" height="32" alt="" class="icon-vip-task" title="Задание V.I.P категории" id="icon_vip_task' . $sh_tasks_row['id'] . '" />';
								}
								
								#Автор задания
								$task_user_avtor = mysql_fetch_array( mysql_query( "SELECT username, id FROM user WHERE id = '" . $sh_tasks_row['iduser'] . "' LIMIT 1" ) );
								
								#Категория задания
								if ($sh_tasks_row['ShownKategories'] == 1 ) { $kategories_task_text = 'Только регистрация'; } else
								if ($sh_tasks_row['ShownKategories'] == 2 ) { $kategories_task_text = 'Только клики'; } else
								if ($sh_tasks_row['ShownKategories'] == 3 ) { $kategories_task_text = 'Регистрация с активностью'; } else
								if ($sh_tasks_row['ShownKategories'] == 4 ) { $kategories_task_text = 'Приглашение в рефералы'; } else
								if ($sh_tasks_row['ShownKategories'] == 5 ) { $kategories_task_text = 'Социальные сети'; } else
								if ($sh_tasks_row['ShownKategories'] == 6 ) { $kategories_task_text = 'YouTube'; } else
								if ($sh_tasks_row['ShownKategories'] == 7 ) { $kategories_task_text = 'Постинг в форумы и/или блоги'; } else
								if ($sh_tasks_row['ShownKategories'] == 8 ) { $kategories_task_text = 'Написать статью или пресс-релиз'; } else
								if ($sh_tasks_row['ShownKategories'] == 9 ) { $kategories_task_text = 'Отзыв/проголосовать'; } else
								if ($sh_tasks_row['ShownKategories'] == 10 ) { $kategories_task_text = 'Forex'; } else
								if ($sh_tasks_row['ShownKategories'] == 11 ) { $kategories_task_text = 'Bitcoin/Litecoin/Dogecoin'; } else
								if ($sh_tasks_row['ShownKategories'] == 12 ) { $kategories_task_text = 'Играть в игры'; } else
								if ($sh_tasks_row['ShownKategories'] == 13 ) { $kategories_task_text = 'Инвестировать'; } else
								if ($sh_tasks_row['ShownKategories'] == 14 ) { $kategories_task_text = 'Мобильные приложения'; } else
								if ($sh_tasks_row['ShownKategories'] == 15 ) { $kategories_task_text = 'Бонусы'; } else
								if ($sh_tasks_row['ShownKategories'] == 16 ) { $kategories_task_text = 'Прочее'; }
								
								#Обрезаем ссылку
								$task_cropped_link = crop_the_link($sh_tasks_row['url'], '50');

								?>
								<script type="text/javascript">
								  $(document).ready(function(){
									$('#icon_standart_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
									$('#icon_24h_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
									$('#icon_vip_task<?=$sh_tasks_row['id']?>').tipTip({defaultPosition:'right'});
								  });
								  function footstep(a) {
									$('#footstep_'+ a +'_off').fadeOut(5);
									$('#footstep_'+ a +'_on').fadeIn(3);
								  }
								</script>
								<tr id="d<?=$sh_tasks_row['id']?>">
								  <td class="normal" width="40" valign="top" >
									<div class="img-icon-task" id="footstep_<?=$sh_tasks_row['id']?>_off">
									  <?=$img_tasks?>
									</div>
									<div class="img-icon-task" id="footstep_<?=$sh_tasks_row['id']?>_on" style="display: none;">
									  <?=$img_tasks_footstep?>
									</div>
								  </td>
								  <td class="normalm" valign="top" >
									<div class="info-show-task">
									  <a href="/tasksview=<?=$sh_tasks_row['id']?>" target="_blank" onclick="footstep(<?=$sh_tasks_row['id']?>);"><?=$sh_tasks_row['title']?></a><br>
									  <span class="desctext"><?=$task_cropped_link?></span> 
									  <span class="desctext">ID:<?=$sh_tasks_row['id']?> - <?=$kategories_task_text?></span>
									</div>
								  </td>
								  <td class="normal" style="text-align: center;" valign="center" nowrap="nowrap" >
									<div class="advertiser-task-show" title="Рекламодатель: <?=$task_user_avtor['username']?>">
									  <a href="/id<?=$task_user_avtor['id']?>"><i class="fa fa-bullhorn advertiser-task-show_link" aria-hidden="true"></i></a>
									</div>
									<span class="clickprice color-grey"><?=moneyraund( $sh_tasks_row['price'], 3 )?> <?=$config['valutaname']?> </span><br>
								  </td>
								  <td class="normal" style="text-align: center; width: 15%;">
									<span title="Одобрено заданий" class="color-green cursor-help"><?=$sh_tasks_row['t_goods']?></span> - 
									<span title="Отклонено заданий" class="color-red cursor-help"><?=$sh_tasks_row['t_bad']?></span> - 
									<span title="На проверке заданий" class="color-grey cursor-help"><?=$sh_tasks_row['t_wait']?></span>
								  </td>
								  <td class="normal" style="width: 6.6%;" >
									<div class="doing-show-task">
									  <a onclick="adv_ell.complaints(<?=$sh_tasks_row['id']?>, 'task');" class="complaints_adv"  target="_blank">
										<i class="glyphicon glyphicon-ban-circle workcomp" aria-hidden="true" title="Пожаловаться на рекламу" ></i>
									  </a>
									</div>
								  </td>
								</tr>
							  <?
							}
						} else {
						  ?>
							<tr>
							  <td colspan="2">
								<div class="inquiry-search-task"><i class="fa fa-info-circle" aria-hidden="true"></i> В данный момент этот список пуст.</div>
								</td>
							</tr>
						  <?
						}
					  ?>
					</tbody>
				</table>
				<div class="navigation-page-task"><? echo navigation( 15, ( int ) $_GET['page'], $tasks_page['count'], 'selected_tasks&p=' ); ?></div>
				<div class="banner_gorizontal banner_gorizontal_fix" style="margin-top: 31px;"><? include_once ROOT_DIR . '/modules/banner468x60/rotator.php';?></div>
			
			</article>
		</div>
		<?
	}
} ?>