Вход Регистрация
Файл: inc/assignments/index.php
Строк: 416
<?
$title
='Задания';
include_once 
'../system/config.php';


echo 
'<img src="http://'.$_SERVER['HTTP_HOST'].'/img/logo.gif">';


if(isset(
$_GET['made']))
{
    
$m mysql_query("SELECT * FROM `assignments_log` WHERE `id_user`='$ku[id]'");
    
    echo 
'<div class="flat-tabs tabs-blue">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tbody>
    <tr>
    <td width="33%" align="center"><a href="/assignments" class="i-tab">Не выполненные</a></td>
    <td width="33%" align="center"><span class="i-tab">Выполненные</span></td>
    </tr>
    </tbody>
    </table>
    </div>'
;
    if(
mysql_num_rows($m) > 0){
        
    while(
$made mysql_fetch_assoc($m))
    {
        
$ass mysql_fetch_assoc(mysql_query("SELECT * FROM `assignments` WHERE `id`='$made[assignment]'"));
        

                
$plant mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ass[plant1]'"));
                
$assUser mysql_fetch_array(mysql_query("SELECT * FROM `assignments_user` WHERE `id_user` = '$ku[id]'"));
                
$plant1 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ass[plant2]'"));
                
$plant2 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ass[plant3]'"));
                
$pet mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$ass[pet1]'"));
                
$pet2 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$ass[pet2]'"));
                
$pet3 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$ass[pet3]'"));
            
                if(
$ass['money']>0){ $a1='<img src="/img/icons/money.png"> '.$ass['money'].', ';  }else{ $a1='';}
                if(
$ass['ruby']>0){ $a2='<img src="/img/icons/ruby.png"> '.$ass['ruby'].', ';  }else{ $a2='';}
                if(
$ass['scarerow']>0){ $a3='<img src="/img/icons/scarerow.png"> '.$ass['scarerow'].' часов, ';  }else{ $a3='';}
                if(
$ass['hydropinics']>0) {$a4='<img src="/img/icons/hydropinics.png"> '.$ass['type_hydropinics'].'% ('.$ass['hydropinics'].' ч.), ';  }else{ $a4='';}
                if(
$ass['exp']>0) {$a5='<img src="/img/icons/experience.png"> '.$ass['exp'].' '; }else{ $a5='';}
                
               
            
            
            echo 
'<div class="flat-content mb0">';
            echo 
'<h2>'.$ass['name'].'</h2>';
            echo 
'<div class="center"><span><div class="clear"></div><div class="center"><div class="center font_zadan mt5 mb-minus4"><b>Требуется для выполнения:</b></div>
            '
;
            if(
$ass['plant1'] > 0) echo '<div class="f-quest-item-big"><span class="f-plant-task-oval f-plant-phase-4" style="background-image: url('/img/plants2/'.$ass['plant1'].'.png')"></span><span class="quest-in-progress">'.$ass['plant-1'].'</span></div>';
            if(
$ass['plant2'] > 0) echo '<div class="f-quest-item-big"><span class="f-plant-task-oval f-plant-phase-4" style="background-image: url('/img/plants2/'.$ass['plant2'].'.png')"></span><span class="quest-in-progress">'.$ass['plant-2'].'</span></div>';
            if(
$ass['plant3'] > 0) echo '<div class="f-quest-item-big"><span class="f-plant-task-oval f-plant-phase-4" style="background-image: url('/img/plants2/'.$ass['plant3'].'.png')"></span><span class="quest-in-progress">'.$ass['plant-3'].'</span></div>';
            echo 
'</div></span></div>';
            echo 
'<div class="mt5">'.$ass['opis'].'</div>';
            echo 
'</div>';
            echo 
'<div class="flat-content bg-lightWheat"><b>Награда:</b> '.$a1.''.$a2.''.$a3.''.$a4.''.$a5.'
            <a  class="flat-btn mt5">Выполнено</a></div>'
;
            
        
    }
    
    }else{
        echo 
'<div class="flat-content mb0">Нет выполненных заданий</div>';
    }
   

    include_once
'../system/foot.php';
    exit;
}

if(isset(
$_GET['id'])){
    
    
$assUser mysql_fetch_array(mysql_query("SELECT * FROM `assignments_user` WHERE `id_user` = '$ku[id]'"));
    
    
$x=mysql_query("SELECT * FROM `assignments` WHERE `id` = '".intval($_GET['id'])."'");
    
$ass=mysql_fetch_assoc($x);
    
    
$log mysql_fetch_array(mysql_query("SELECT * FROM `assignments_log` WHERE `id_user` = '$ku[id]' AND `assignment` ='".$ass['id']."'"));
    
$key mysql_fetch_array(mysql_query("SELECT * FROM `key_user` WHERE `id_user` = '$ku[id]'"));
       
        if(isset(
$_GET['go']) && ($ku['level']>=$ass['level'] && $assUser['assignment']<&& $log<1)){
            
mysql_query("UPDATE `assignments_user` SET `assignment` = '$ass[id]' WHERE `id_user` = '$ku[id]'");
            
header("Location: /assignments/");
        }
        if(isset(
$_GET['no']) && ($assUser['assignment']>&& $log<1)){
            
mysql_query("UPDATE `assignments_user` SET `assignment` = '0', `plant1` = '0', `plant2` = '0', `plant3` = '0', `pet1` = '0', `pet2` = '0', `pet3` = '0' WHERE `id_user` = '$ku[id]'");
            
header("Location: /assignments/");
        }
        if(isset(
$_GET['prize']) && ($assUser['assignment']>&& $log<&& $assUser['plant1']>=$ass['plant-1'] && $assUser['plant2']>=$ass['plant-2'] && $assUser['plant3']>=$ass['plant-3'] && $assUser['pet1']>=$ass['pet-1'] && $assUser['pet2']>=$ass['pet-2'] && $assUser['pet3']>=$ass['pet-3'])){
            
mysql_query("UPDATE `assignments_user` SET `assignment` = '0', `plant1` = '0', `plant2` = '0', `plant3` = '0', `pet1` = '0', `pet2` = '0', `pet3` = '0' WHERE `id_user` = '$ku[id]'");
            if(
$ass['money']>0){
                
$money=$ass['money'];
                
$ku['money']=plus_money($money);
            }
            if(
$ass['ruby']>0){
                
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']+$ass['ruby'])."' WHERE `id` = '$ku[id]'"); 
                
mysql_query("INSERT INTO `info_user` SET `id_user` = '$ku[id]', `status` = '+', `many` = '$ass[ruby]', `kuda` = 'Награда за задание', `time` = '$time'");
            }
            if(
$ass['scarerow']>0){ 
                
$timee=3600*$ass['scarerow'];
                
mysql_query("UPDATE `kolhoz_user` SET `scarecrow_time` = '".($ku['scarecrow_time']>$time?($ku['scarecrow_time']+$timee):($time+$timee))."' WHERE `id` = '$ku[id]'");
            }

            if(
$ass['hydropinics']>0){
                
$timee=3600*$ass['hydropinics'];
                
$ps=$ku['hydropinics_type']+$ass['type_hydropinics'];
                if(
$ps>300)$ps=300;
                
mysql_query("UPDATE `kolhoz_user` SET `hydropinics_time` = '".($ku['hydropinics_time']>$time?($ku['hydropinics_time']+$timee):($time+$timee))."', `hydropinics_type` = '$ps' WHERE `id` = '$ku[id]'");
            }
            if(
$ass['exp']>0){
                
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$ass['exp'])."' WHERE `id` = '$ku[id]'"); 
            }
     
            
mysql_query("INSERT INTO `assignments_log` SET `id_user` = '$ku[id]', `assignment` = '$ass[id]', `time` = '$time'");
            
$_SESSION['msg'] = 'Вы усешно выполнили задание!';
            
header("Location: /assignments/");
        }
}



$count mysql_result(mysql_query("SELECT COUNT(`id`) FROM `assignments_user` WHERE `id_user` = '$ku[id]' and `assignment` > 0"),0);

if(
$count 0){
    echo 
'<div class="flat-tabs tabs-blue">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tbody>
    <tr>
    <td width="33%" align="center"><span class="i-tab">Выполняемое</span></td>
    <td width="33%" align="center"><a href="/assignments?made" class="i-tab">Выполненные</a></td>
    </tr>
    </tbody>
    </table>
    </div>'
;
            
$xx=mysql_query("SELECT * FROM `assignments_user` WHERE `id_user` = '".$ku['id']."'");
            
$as=mysql_fetch_assoc($xx);
            
            
$x=mysql_query("SELECT * FROM `assignments` WHERE `id` = '".$as['assignment']."'");
            
$ass=mysql_fetch_assoc($x);
            
            
$log mysql_fetch_array(mysql_query("SELECT * FROM `assignments_log` WHERE `id_user` = '$ku[id]' AND `assignment` ='".$ass['id']."'"));
            if(
$log<1){
                
$plant mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ass[plant1]'"));
                
$assUser mysql_fetch_array(mysql_query("SELECT * FROM `assignments_user` WHERE `id_user` = '$ku[id]'"));
                
$plant1 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ass[plant2]'"));
                
$plant2 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ass[plant3]'"));
                
$pet mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$ass[pet1]'"));
                
$pet2 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$ass[pet2]'"));
                
$pet3 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$ass[pet3]'"));
            
                if(
$ass['money']>0$a1='<img src="/img/icons/money.png"> '.$ass['money'].', ';
                if(
$ass['ruby']>0$a2='<img src="/img/icons/ruby.png"> '.$ass['ruby'].', ';
                if(
$ass['scarerow']>0$a3='<img src="/img/icons/scarerow.png"> '.$ass['scarerow'].' часов, ';
                if(
$ass['hydropinics']>0$a4='<img src="/img/icons/hydropinics.png"> '.$ass['type_hydropinics'].'% ('.$ass['hydropinics'].' ч.), ';
                if(
$ass['exp']>0$a5='<img src="/img/icons/experience.png"> '.$ass['exp'].' ';
                
               
            
            
            echo 
'<div class="flat-content mb0">';
            echo 
'<h2>'.$ass['name'].'</h2>';
            echo 
'<div class="center"><span><div class="clear"></div><div class="center"><div class="center font_zadan mt5 mb-minus4"><b>Требуется для выполнения:</b></div>
            '
;
            if(
$ass['plant1'] > 0) echo '<div class="f-quest-item-big"><span class="f-plant-task-oval f-plant-phase-4" style="background-image: url('/img/plants2/'.$ass['plant1'].'.png')"></span><span class="quest-in-progress">'.$assUser['plant1'].'/'.$ass['plant-1'].'</span></div>';
            if(
$ass['plant2'] > 0) echo '<div class="f-quest-item-big"><span class="f-plant-task-oval f-plant-phase-4" style="background-image: url('/img/plants2/'.$ass['plant2'].'.png')"></span><span class="quest-in-progress">'.$assUser['plant2'].'/'.$ass['plant-2'].'</span></div>';
            if(
$ass['plant3'] > 0) echo '<div class="f-quest-item-big"><span class="f-plant-task-oval f-plant-phase-4" style="background-image: url('/img/plants2/'.$ass['plant3'].'.png')"></span><span class="quest-in-progress">'.$assUser['plant3'].'/'.$ass['plant-3'].'</span></div>';
            echo 
'</div></span></div>';
            echo 
'<div class="mt5">'.$ass['opis'].'</div>';
            echo 
'</div>';
            echo 
'<div class="flat-content bg-lightWheat"><b>Награда:</b> '.$a1.''.$a2.''.$a3.''.$a4.''.$a5.'';
            
            if(
$ass['id']==$assUser['assignment'] && $assUser['plant1']>=$ass['plant-1'] && $assUser['plant2']>=$ass['plant-2'] && $assUser['plant3']>=$ass['plant-3'] && $assUser['pet1']>=$ass['pet-1'] && $assUser['pet2']>=$ass['pet-2'] && $assUser['pet3']>=$ass['pet-3'])echo'<a class="flat-btn mt5" href="/assignments/id/'.$ass['id'].'/prize">Забрать награду</a>';
            if(
$assUser['assignment']>&& $ass['id']==$assUser['assignment'])echo'<a class="flat-btn mt5" href="/assignments/id/'.$ass['id'].'/no"> Отказаться</a>'
            echo 
'</div>';
            }
    
    
    include_once
'../system/foot.php';
}else{

    echo 
'<div class="flat-tabs tabs-blue">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tbody>
    <tr>
    <td width="33%" align="center"><span class="i-tab">Не выполненные</span></td>
    <td width="33%" align="center"><a href="/assignments?made" class="i-tab">Выполненные</a></td>
    </tr>
    </tbody>
    </table>
    </div>
    '
;
    
$k_post mysql_result(mysql_query("SELECT COUNT(*) FROM `assignments` WHERE `level` <= '".$ku['level']."'"),0);
    if (
$k_post==0)
    {
    echo 
"<div class='div'>Нет заданий</div>";
    }

    
$k_page=k_page($k_post,$set['p_str']);
    
$page=page($k_page);
    
$start=$set['p_str']*$page-$set['p_str'];

    
$xx mysql_query("SELECT * FROM `assignments` WHERE `level` <= '".$ku['level']."'  ORDER BY level ASC LIMIT $start$set[p_str]");
    while(
$ass=mysql_fetch_assoc($xx)){
        
            
$log mysql_fetch_array(mysql_query("SELECT * FROM `assignments_log` WHERE `id_user` = '$ku[id]' AND `assignment` ='".$ass['id']."'"));
            
            if(
$log<1){
                
$plant mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ass[plant1]'"));
                
$assUser mysql_fetch_array(mysql_query("SELECT * FROM `assignments_user` WHERE `id_user` = '$ku[id]'"));
                
$plant1 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ass[plant2]'"));
                
$plant2 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ass[plant3]'"));
                
$pet mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$ass[pet1]'"));
                
$pet2 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$ass[pet2]'"));
                
$pet3 mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$ass[pet3]'"));
            
                if(
$ass['money']>0){ $a1='<img src="/img/icons/money.png"> '.$ass['money'].', ';  }else{ $a1='';}
                if(
$ass['ruby']>0){ $a2='<img src="/img/icons/ruby.png"> '.$ass['ruby'].', ';  }else{ $a2='';}
                if(
$ass['scarerow']>0){ $a3='<img src="/img/icons/scarerow.png"> '.$ass['scarerow'].' часов, ';  }else{ $a3='';}
                if(
$ass['hydropinics']>0) {$a4='<img src="/img/icons/hydropinics.png"> '.$ass['type_hydropinics'].'% ('.$ass['hydropinics'].' ч.), ';  }else{ $a4='';}
                if(
$ass['exp']>0) {$a5='<img src="/img/icons/experience.png"> '.$ass['exp'].' '; }else{ $a5='';}
                
               
            
            
            echo 
'<div class="flat-content mb0">';
            echo 
'<h2>'.$ass['name'].'</h2>';
            echo 
'<div class="center"><span><div class="clear"></div><div class="center"><div class="center font_zadan mt5 mb-minus4"><b>Требуется для выполнения:</b></div>
            '
;
            if(
$ass['plant1'] > 0) echo '<div class="f-quest-item-big"><span class="f-plant-task-oval f-plant-phase-4" style="background-image: url('/img/plants2/'.$ass['plant1'].'.png')"></span><span class="quest-in-progress">'.$ass['plant-1'].'</span></div>';
            if(
$ass['plant2'] > 0) echo '<div class="f-quest-item-big"><span class="f-plant-task-oval f-plant-phase-4" style="background-image: url('/img/plants2/'.$ass['plant2'].'.png')"></span><span class="quest-in-progress">'.$ass['plant-2'].'</span></div>';
            if(
$ass['plant3'] > 0) echo '<div class="f-quest-item-big"><span class="f-plant-task-oval f-plant-phase-4" style="background-image: url('/img/plants2/'.$ass['plant3'].'.png')"></span><span class="quest-in-progress">'.$ass['plant-3'].'</span></div>';
            echo 
'</div></span></div>';
            echo 
'<div class="mt5">'.$ass['opis'].'</div>';
            echo 
'</div>';
            echo 
'<div class="flat-content bg-lightWheat"><b>Награда:</b> '.$a1.''.$a2.''.$a3.''.$a4.''.$a5.'
            <a href="/assignments/id/'
.$ass['id'].'/go" class="flat-btn mt5">Начать выполнение</a></div>';
            }
        


    }
    if (
$k_page>1)str("/assignments/",$k_page,$page);

  include_once
'../system/foot.php';
}

?>
Онлайн: 1
Реклама