<?php
include 'core/system.php';

head('Вещи на питомце');

reg();
$sql = $dbc->query("SELECT * FROM `art_pet` WHERE `user_id`='".$user['id']."' AND `status` = 2 ORDER by `art_id` ");

$total = $dbc->query("SELECT `id` FROM `art_pet` where `user_id` ='".$user['id']."' AND `status` = 2 "); $total = $total->num_rows;


if($total==0){
echo '<div class="main"><div class="block_zero center">на питомце ничего не одето!</div></div>';

    foot();
    exit;
}
while($row = $sql->fetch_assoc()){
if($row['mag']==1){ $mag =' style="box-shadow: 0px 0px 20px blue; margin: 2px;">';}




elseif($row['mag']==2){ $mag =' style="box-shadow: 0px 0px 20px violet; margin: 2px;">';}




elseif($row['mag']==3){ $mag =' style="box-shadow: 0px 0px 20px gold; margin: 2px;">';}

elseif($row['mag']==0){ $mag ='>';}






if($row['craft']>0){ $fla = '<span class="info">+'.$row['craft'].''; }else{ $fla = '';} 
?><div class="sblue-panel"><div class="panel-inner-3"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="37" style="vertical-align: top;"><img width="32"height="32" src="img/item_pet/<?=$row['img']?>.png" alt="."border="0" <?=$mag?></td><td><div><a href="/info_it.php?ids=<?=$row['id']?>" class="<?=$row['lite']?>"><center><?=$row['nik']?></a><?=$fla?></center></div><span class="nowrap"></span> <span class="nowrap"></span><span class="clearer"></span></td><td width="60"><a href="/pet_item.php?id=<?=$row['id']?><??>&amp;off" class="gr-btn center"><span>Снять</span></a></td></tr></table></div></div><?











echo' </div>';
if(isset($_GET['off']) and !empty($_GET['id'])){
    $pet_id = int($_GET['id']);
$pet = $dbc->query("SELECT * FROM `art_pet` WHERE `id`='".$pet_id."' AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc();


if(!$pet){
        header("Location: pet_item.php");

        exit;
        }
        if($pet['status']==1){
        header("Location: pet_item.php");

        exit;
        }
        
if($pet['tip']==1){    $dbc->query("UPDATE `user_pets` SET `str`=`str`-'".$pet['strong']."',`vit`=`vit`-'".$pet['hp']."',`def`=`def`-'".$pet['prot']."',`weapon`=0 WHERE `id_user`='".$user['id']."'");} 


if($pet['tip']==2){    $dbc->query("UPDATE `user_pets` SET `str`=`str`-'".$pet['strong']."',`vit`=`vit`-'".$pet['hp']."',`def`=`def`-'".$pet['prot']."',`head`=0 WHERE `id_user`='".$user['id']."'");} 

if($pet['tip']==3){    $dbc->query("UPDATE `user_pets` SET `str`=`str`-'".$pet['strong']."',`vit`=`vit`-'".$pet['hp']."',`def`=`def`-'".$pet['prot']."',`armor`=0 WHERE `id_user`='".$user['id']."'");} 
    $dbc->query("UPDATE `art_pet` SET `status`=1 WHERE `id`='".$pet_id."'");


$_SESSION['message'] = 'Вы сняли с питомца '.$pet[nik].'';

header('Location: pet_item.php?');exit();

        foot();
}
}
foot();
?>


