<?php
  
ECHO "<div class='navigation'>";
ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "<a href='/id".$account['ID']."'>".TEXT_ABSOLUTE($account['LOGIN'])."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "".LG('Подарки')."";
ECHO "</div>";

$column = DB::GET_COLUMN("SELECT COUNT(`ID`) FROM `GIFTS_USER` WHERE `MY_ID` = '".$account['ID']."'");
$spage = SPAGE($column, $page_settings);
$page = PAGE($spage);
$limit = $page_settings * $page - $page_settings;

IF (ISSET($user) && $account['ID'] != $user['ID']){
  
  ECHO "<div class='list'>";
  ECHO "<a href='/users/profile/?path=gifts&section=give&id=".$account['ID']."' class='btn'>".ICONS('gift', 15, 'fa-fw')." ".LG('Подарить подарок')."</a>";  
  ECHO "</div>";
  
}

IF ($column == 0){
  
  HTML::EMPTY();
  
}ELSE{
  
  ECHO "<div class='list-body'>";
  
}

IF (GET('delete') && ISSET($user) && DB::GET_COLUMN("SELECT COUNT(`ID`) FROM `GIFTS_USER` WHERE `MY_ID` = '".$account['ID']."' AND `ID` = '".INTVAL(GET('delete'))."' LIMIT 1") == 1 && $account['ID'] == $user['ID']){
  
  IF (GET('get') == 'delete_ok'){
    
    DB::GET_SET("DELETE FROM `GIFTS_USER` WHERE `MY_ID` = '".$account['ID']."' AND `ID` = '".INTVAL(GET('delete'))."' LIMIT 1");
    
    REDIRECT('/users/profile/?path=gifts&id='.$account['ID'].'');
    
  }
  
  ECHO "<div class='list-menu'>";
  ECHO "".LG('Вы действительно хотите удалить подарок?')."<br /><br />";
  ECHO "<a href='/users/profile/?path=gifts&id=".$account['ID']."&delete=".INTVAL(GET('delete'))."&get=delete_ok' class='btn'>".ICONS('trash', 15, 'fa-fw')." ".LG('Удалить')."</a>";
  ECHO "<a href='/users/profile/?path=gifts&id=".$account['ID']."' class='btn-o'>".LG('Отмена')."</a>";
  ECHO "</div>";
  
}

$data = DB::GET_STRING_ALL("SELECT * FROM `GIFTS_USER` WHERE `MY_ID` = '".$account['ID']."' ORDER BY `TIME` DESC LIMIT ".$limit.", ".$page_settings."");

WHILE ($list = $data->FETCH()){
  
  $gift = DB::GET_STRING("SELECT * FROM `GIFTS` WHERE `ID` = '".$list['GIFT_ID']."' LIMIT 1");
  
  ECHO "<div class='list-menu'>";
  
  ECHO "<img class='img' src='/files/upload/gifts/".$gift['ID'].".".$gift['EXT']."'><br /><br />";
  
  ECHO "<b>".LG('Название').":</b> ".TEXT_ABSOLUTE($gift['NAME'])."<br />";
  ECHO "<b>".LG('Цена').":</b> ".MONEY($gift['SUM'], CONFIG('MONEY'), 1)."<br />";
  ECHO "<b>".LG('Подарил').":</b> ";
  
  IF ($list['PRIVATE'] == 0){
    
    ECHO "".USER::LOGIN($list['USER_ID'], 1, 1)."";
    
  }ELSEIF ($list['PRIVATE'] == 1){
    
    IF ($list['MY_ID'] != $user['ID'] && $list['USER_ID'] != $user['ID']){
      
      ECHO "<span class='icons'>".ICONS('lock', 18, 'fa-fw')."".LG('Логин скрыт')."</span>";
    
    }ELSE{
      
      ECHO "".USER::LOGIN($list['USER_ID'], 1, 1)."";
    
    } 
  
  }
  
  IF (STR($list['MESSAGE']) > 0){
    
    ECHO "<br /><b>".LG('Сообщение').":</b> ";
    
    IF ($list['PRIVATE'] == 0){
      
      ECHO "".TEXT_ABSOLUTE($list['MESSAGE'])."";
    
    }ELSEIF ($list['PRIVATE'] == 1){
      
      IF ($list['MY_ID'] != $user['ID'] && $list['USER_ID'] != $user['ID']){
        
        ECHO "<span class='icons'>".ICONS('lock', 18, 'fa-fw')."".LG('Сообщение скрыто')."</span>";
        
      }ELSE{
        
        ECHO "77".TEXT_ABSOLUTE($list['MESSAGE'])."";
        
      }
    
    }
    
  }
  
  IF (ISSET($user) && $account['ID'] == $user['ID']){
    
    ECHO "<br /><br /><a href='/users/profile/?path=gifts&id=".$account['ID']."&delete=".$list['ID']."' class='btn-o'>".ICONS('trash', 15, 'fa-fw')." ".LG('Удалить')."</a>";
    
  }
  
  ECHO "</div>";
  
}

IF ($column > 0){
  
  ECHO "</div>";
  
}

IF ($spage > 1){ ECHO STR_PAGE('/users/profile/?path=gifts&id='.$account['ID'].'&', $spage, $page); }

ECHO "<div class='navigation'>";
ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "<a href='/id".$account['ID']."'>".TEXT_ABSOLUTE($account['LOGIN'])."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "".LG('Подарки')."";
ECHO "</div>";
  
?>