<?php
include_once ('./core/base.php');
falseauth();

$id=fl($_GET['id']);

$quest = $base -> query('SELECT * FROM `users_quests` WHERE `user` = "'.$u['id'].'" AND `id` = "'.$id.'" LIMIT 1') -> fetch_assoc();

$header = ''.$quest['name'].'';

include_once ('./core/head.php');

if($quest != 0) {

echo '<div class="b"><div class="title">'.$quest['name'].'</div>';
echo ''.quest($quest['id']).'';
echo '<div class="line"></div>';
echo '<center><small>'.$quest['text'].'</small></center>';
echo '<div class="line"></div>';
echo '<div class="title">Информация</div>';

$time_to_reload = intval((60 * 60) * 12);
$time_quest_reload = intval(($quest['finish_time'] + $time_reload_quest) - time());

if($quest['type'] == 'kill'){
	echo '<table class="table table-common" style="margin-top: 5px; border-collapse: collapse; text-align: left;">';
	echo '<tr><td><img src="/images/icons/page.png"> Прогресс задания</td><td><center>'.$quest['mob_already_killed'].'/'.$quest['kill_mob_count'].'</center></td></tr>';
	if($quest['status'] == 'finished' AND $quest['daily'] == 'yes') echo '<tr><td><img src="/images/icons/time.png"> До повторного выполнения</td><td><center>'.tl($time_quest_reload).'</center></td></tr>';
	echo '</table>';
}elseif($quest['type'] == 'resource'){
	$uitem = $base -> query('SELECT * FROM `users_items` WHERE `ident_id` = "'.$quest['resource_need_id'].'" AND `user` = "'.$u['id'].'" LIMIT 1') -> fetch_assoc();
	if($uitem['amount'] == '') $uitem['amount'] = 0;
	echo '<table class="table table-common" style="margin-top: 5px; border-collapse: collapse; text-align: left;">';
	echo '<tr><td><img src="/images/icons/page.png"> Прогресс задания</td><td><center>'.$uitem['amount'].'/'.$quest['resource_need_amount'].'</center></td></tr>';
	if($quest['status'] == 'finished' AND $quest['daily'] == 'yes') echo '<tr><td><img src="/images/icons/time.png"> До повторного выполнения</td><td><center>'.tl($time_quest_reload).'</center></td></tr>';
	echo '</table>';
}

echo '<div class="title">Награды</div>';
echo '<div class="event">';
	if($quest['reward_exp'] > 0) echo '<img src="/images/icons/exp.png"> Опыт: '.n_f($quest['reward_exp']).'<br/>';
	if($quest['reward_silver'] > 0) echo '<img src="/images/icons/silver_24.png"> Серебро: '.n_f($quest['reward_silver']).'<br/>';
	if($quest['reward_gold'] > 0) echo '<img src="/images/icons/gold_24.png"> Золото: <font color="gold">'.n_f($quest['reward_gold']).'</font><br/>';
	if($quest['reward_item'] > 0){
		$r_item = $base -> query('SELECT * FROM `items` WHERE `id` = "'.$quest['reward_item'].'" LIMIT 1') -> fetch_assoc();
		if($r_item['mark'] == '0') $color = 'B1B1B1';
		if($r_item['mark'] == '1') $color = '30C030';
		if($r_item['mark'] == '2') $color = '68A8F9';
		if($r_item['mark'] == '3') $color = 'D8CD32';
		if($r_item['mark'] == '4') $color = 'DD4FFF';
		if($r_item['what'] == 'clothing') echo '<img src="/images/items/'.$r_item['type'].'/'.$r_item['image'].'.png" width="24px" style="border: 1px solid #'.$color.';"> <font color="#'.$color.'">'.$r_item['name'].'</font> '.$quest['reward_item_amount'].'шт.';
		else echo '<img src="/images/items/resource/'.$r_item['image'].'.png" width="24px" style="border: 1px solid #'.$color.';"> <font color="#'.$color.'">'.$r_item['name'].'</font> '.$quest['reward_item_amount'].'шт.';
	}
echo '</div>';

echo '<br/><a class="btn" href="javascript:history.go(-1)"><img src="/images/icons/back.png"> Назад</a>';

echo '</div>';

}else{
header('Location: /inventory/res/');
exit;
}


include_once ('./core/foot.php');
?>