<?php
  
ACCESS('users');
  
IF ($account['ID'] != $user['ID']){
  
  REDIRECT('/');
  
}
  
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 "<a href='/users/profile/?path=form&id=".$account['ID']."'>".LG('Личная информация')."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "".LG('Общая информация')."";
ECHO "</div>";

IF (POST('ok')){
  
  $err_data = 0;
  
  $name = ADSL(POST('name'));
  $surname = ADSL(POST('surname'));
  $g_r = INTVAL(POST('g_r'));
  $m_r = INTVAL(POST('m_r'));
  $d_r = INTVAL(POST('d_r'));
  $sex = INTVAL(POST('sex'));
  
  IF (STR($name) > 120){
    
    ERROR('Имя не может быть больше 120 символов', 'session');
    $err_data = 1;
    
  }
  
  IF (STR($surname) > 120){
    
    ERROR('Фамилия не может быть больше 120 символов', 'session');
    $err_data = 1;
    
  }
  
  IF ($err_data == 1){
    
    REDIRECT('/users/profile/?path=form&id='.$account['ID'].'&section=general_info');
    
  }
  
  DB::GET_SET("UPDATE `USERS_SETTINGS` SET `G_R` = '".$g_r."', `M_R` = '".$m_r."', `D_R` = '".$d_r."', `NAME` = '".$name."', `SURNAME` = '".$surname."' WHERE `USER_ID` = '".$account['ID']."' LIMIT 1");
  
  DB::GET_SET("UPDATE `USERS` SET `SEX` = '".$sex."' WHERE `ID` = '".$account['ID']."' LIMIT 1");
  
  SUCCESS('Изменения успешно приняты', 'session');
  REDIRECT('/users/profile/?path=form&id='.$account['ID']);
  
}

ECHO "<div class='list'>";

ECHO "<form method='post' class='form' action='/users/profile/?path=form&id=".$account['ID']."&section=general_info'>";

ECHO "<b>".LG('Имя')."</b>:<br />";
HTML::INPUT('name', NULL, NULL, NULL, TEXT_ABSOLUTE($account_set['NAME']));

ECHO "<b>".LG('Фамилия')."</b>:<br />";
HTML::INPUT('surname', NULL, NULL, NULL, TEXT_ABSOLUTE($account_set['SURNAME']));

ECHO "<b>".LG('Дата рождения')."</b>:<br />";

?>
<select name="d_r" class="form-control-select" style="width: 100px;">  
<option value="0" <?ECHO "".($account_set['D_R'] == NULL ? "selected='selected'" : NULL)."";?> ><?=LG('День')?></option>
<option value="1" <?ECHO "".($account_set['D_R'] == 1 ? "selected='selected'" : NULL)."";?> >01</option>
<option value="2" <?ECHO "".($account_set['D_R'] == 2 ? "selected='selected'" : NULL)."";?> >02</option>
<option value="3" <?ECHO "".($account_set['D_R'] == 3 ? "selected='selected'" : NULL)."";?> >03</option>
<option value="4" <?ECHO "".($account_set['D_R'] == 4 ? "selected='selected'" : NULL)."";?> >04</option>
<option value="5" <?ECHO "".($account_set['D_R'] == 5 ? "selected='selected'" : NULL)."";?> >05</option>
<option value="6" <?ECHO "".($account_set['D_R'] == 6 ? "selected='selected'" : NULL)."";?> >06</option>
<option value="7" <?ECHO "".($account_set['D_R'] == 7 ? "selected='selected'" : NULL)."";?> >07</option>
<option value="8" <?ECHO "".($account_set['D_R'] == 8 ? "selected='selected'" : NULL)."";?> >08</option>
<option value="9" <?ECHO "".($account_set['D_R'] == 9 ? "selected='selected'" : NULL)."";?> >09</option>
<option value="10" <?ECHO "".($account_set['D_R'] == 10 ? "selected='selected'" : NULL)."";?> >10</option>
<option value="11" <?ECHO "".($account_set['D_R'] == 11 ? "selected='selected'" : NULL)."";?> >11</option>
<option value="12" <?ECHO "".($account_set['D_R'] == 12 ? "selected='selected'" : NULL)."";?> >12</option>
<option value="13" <?ECHO "".($account_set['D_R'] == 13 ? "selected='selected'" : NULL)."";?> >13</option>
<option value="14" <?ECHO "".($account_set['D_R'] == 14 ? "selected='selected'" : NULL)."";?> >14</option>
<option value="15" <?ECHO "".($account_set['D_R'] == 15 ? "selected='selected'" : NULL)."";?> >15</option>
<option value="16" <?ECHO "".($account_set['D_R'] == 16 ? "selected='selected'" : NULL)."";?> >16</option>
<option value="17" <?ECHO "".($account_set['D_R'] == 17 ? "selected='selected'" : NULL)."";?> >17</option>
<option value="18" <?ECHO "".($account_set['D_R'] == 18 ? "selected='selected'" : NULL)."";?> >18</option>
<option value="19" <?ECHO "".($account_set['D_R'] == 19 ? "selected='selected'" : NULL)."";?> >19</option>
<option value="20" <?ECHO "".($account_set['D_R'] == 20 ? "selected='selected'" : NULL)."";?> >20</option>
<option value="21" <?ECHO "".($account_set['D_R'] == 21 ? "selected='selected'" : NULL)."";?> >21</option>
<option value="22" <?ECHO "".($account_set['D_R'] == 22 ? "selected='selected'" : NULL)."";?> >22</option>
<option value="23" <?ECHO "".($account_set['D_R'] == 23 ? "selected='selected'" : NULL)."";?> >23</option>
<option value="24" <?ECHO "".($account_set['D_R'] == 24 ? "selected='selected'" : NULL)."";?> >24</option>
<option value="25" <?ECHO "".($account_set['D_R'] == 25 ? "selected='selected'" : NULL)."";?> >25</option>
<option value="26" <?ECHO "".($account_set['D_R'] == 26 ? "selected='selected'" : NULL)."";?> >26</option>
<option value="27" <?ECHO "".($account_set['D_R'] == 27 ? "selected='selected'" : NULL)."";?> >27</option>
<option value="28" <?ECHO "".($account_set['D_R'] == 28 ? "selected='selected'" : NULL)."";?> >28</option>
<option value="29" <?ECHO "".($account_set['D_R'] == 29 ? "selected='selected'" : NULL)."";?> >29</option>
<option value="30" <?ECHO "".($account_set['D_R'] == 30 ? "selected='selected'" : NULL)."";?> >30</option>
<option value="31" <?ECHO "".($account_set['D_R'] == 31 ? "selected='selected'" : NULL)."";?> >31</option>
</select>

<select name="m_r" class="form-control-select" style="width: 100px;">
<option value="0" <?ECHO "".($account_set['M_R'] == NULL ? "selected='selected'" : NULL)."";?> ><?=LG('Месяц')?></option>	
<option value="1" <?ECHO "".($account_set['M_R'] == 1 ? "selected='selected'" : NULL)."";?> ><?=LG('Января')?></option>
<option value="2" <?ECHO "".($account_set['M_R'] == 2 ? "selected='selected'" : NULL)."";?> ><?=LG('Февраля')?></option>
<option value="3" <?ECHO "".($account_set['M_R'] == 3 ? "selected='selected'" : NULL)."";?> ><?=LG('Марта')?></option>
<option value="4" <?ECHO "".($account_set['M_R'] == 4 ? "selected='selected'" : NULL)."";?> ><?=LG('Апреля')?></option>
<option value="5" <?ECHO "".($account_set['M_R'] == 5 ? "selected='selected'" : NULL)."";?> ><?=LG('Мая')?></option>
<option value="6" <?ECHO "".($account_set['M_R'] == 6 ? "selected='selected'" : NULL)."";?> ><?=LG('Июня')?></option>
<option value="7" <?ECHO "".($account_set['M_R'] == 7 ? "selected='selected'" : NULL)."";?> ><?=LG('Июля')?></option>
<option value="8" <?ECHO "".($account_set['M_R'] == 8 ? "selected='selected'" : NULL)."";?> ><?=LG('Августа')?></option>
<option value="9" <?ECHO "".($account_set['M_R'] == 9 ? "selected='selected'" : NULL)."";?> ><?=LG('Сентября')?></option>
<option value="10" <?ECHO "".($account_set['M_R'] == 10 ? "selected='selected'" : NULL)."";?> ><?=LG('Октября')?></option>
<option value="11" <?ECHO "".($account_set['M_R'] == 11 ? "selected='selected'" : NULL)."";?> ><?=LG('Ноября')?></option>
<option value="12" <?ECHO "".($account_set['M_R'] == 12 ? "selected='selected'" : NULL)."";?> ><?=LG('Декабря')?></option>
</select>

<select name="g_r" class="form-control-select" style="width: 100px;">
<option value="0" <?ECHO "".($account_set['G_R'] == NULL ? "selected='selected'" : NULL)."";?> ><?=LG('Год')?></option>
<option value="2015" <?ECHO "".($account_set['G_R'] == 2015 ? "selected='selected'" : NULL)."";?> >2015</option>    
<option value="2014" <?ECHO "".($account_set['G_R'] == 2014 ? "selected='selected'" : NULL)."";?> >2014</option>    
<option value="2013" <?ECHO "".($account_set['G_R'] == 2013 ? "selected='selected'" : NULL)."";?> >2013</option>    
<option value="2012" <?ECHO "".($account_set['G_R'] == 2012 ? "selected='selected'" : NULL)."";?> >2012</option>    
<option value="2011" <?ECHO "".($account_set['G_R'] == 2011 ? "selected='selected'" : NULL)."";?> >2011</option>    
<option value="2010" <?ECHO "".($account_set['G_R'] == 2010 ? "selected='selected'" : NULL)."";?> >2010</option>    
<option value="2009" <?ECHO "".($account_set['G_R'] == 2009 ? "selected='selected'" : NULL)."";?> >2009</option>    
<option value="2008" <?ECHO "".($account_set['G_R'] == 2008 ? "selected='selected'" : NULL)."";?> >2008</option>    
<option value="2007" <?ECHO "".($account_set['G_R'] == 2007 ? "selected='selected'" : NULL)."";?> >2007</option>    
<option value="2006" <?ECHO "".($account_set['G_R'] == 2006 ? "selected='selected'" : NULL)."";?> >2006</option>    
<option value="2005" <?ECHO "".($account_set['G_R'] == 2005 ? "selected='selected'" : NULL)."";?> >2005</option>
<option value="2004" <?ECHO "".($account_set['G_R'] == 2004 ? "selected='selected'" : NULL)."";?> >2004</option>
<option value="2003" <?ECHO "".($account_set['G_R'] == 2003 ? "selected='selected'" : NULL)."";?> >2003</option>
<option value="2002" <?ECHO "".($account_set['G_R'] == 2002 ? "selected='selected'" : NULL)."";?> >2002</option>
<option value="2001" <?ECHO "".($account_set['G_R'] == 2001 ? "selected='selected'" : NULL)."";?> >2001</option>
<option value="2000" <?ECHO "".($account_set['G_R'] == 2000 ? "selected='selected'" : NULL)."";?> >2000</option>
<option value="1999" <?ECHO "".($account_set['G_R'] == 1999 ? "selected='selected'" : NULL)."";?> >1999</option>
<option value="1998" <?ECHO "".($account_set['G_R'] == 1998 ? "selected='selected'" : NULL)."";?> >1998</option>
<option value="1997" <?ECHO "".($account_set['G_R'] == 1997 ? "selected='selected'" : NULL)."";?> >1997</option>
<option value="1996" <?ECHO "".($account_set['G_R'] == 1996 ? "selected='selected'" : NULL)."";?> >1996</option>
<option value="1995" <?ECHO "".($account_set['G_R'] == 1995 ? "selected='selected'" : NULL)."";?> >1995</option>
<option value="1994" <?ECHO "".($account_set['G_R'] == 1994 ? "selected='selected'" : NULL)."";?> >1994</option>
<option value="1993" <?ECHO "".($account_set['G_R'] == 1993 ? "selected='selected'" : NULL)."";?> >1993</option>
<option value="1992" <?ECHO "".($account_set['G_R'] == 1992 ? "selected='selected'" : NULL)."";?> >1992</option>
<option value="1991" <?ECHO "".($account_set['G_R'] == 1991 ? "selected='selected'" : NULL)."";?> >1991</option>
<option value="1990" <?ECHO "".($account_set['G_R'] == 1990 ? "selected='selected'" : NULL)."";?> >1990</option>
<option value="1989" <?ECHO "".($account_set['G_R'] == 1989 ? "selected='selected'" : NULL)."";?> >1989</option>
<option value="1988" <?ECHO "".($account_set['G_R'] == 1988 ? "selected='selected'" : NULL)."";?> >1988</option>
<option value="1987" <?ECHO "".($account_set['G_R'] == 1987 ? "selected='selected'" : NULL)."";?> >1987</option>
<option value="1986" <?ECHO "".($account_set['G_R'] == 1986 ? "selected='selected'" : NULL)."";?> >1986</option>
<option value="1985" <?ECHO "".($account_set['G_R'] == 1985 ? "selected='selected'" : NULL)."";?> >1985</option>
<option value="1984" <?ECHO "".($account_set['G_R'] == 1984 ? "selected='selected'" : NULL)."";?> >1984</option>
<option value="1983" <?ECHO "".($account_set['G_R'] == 1983 ? "selected='selected'" : NULL)."";?> >1983</option>
<option value="1982" <?ECHO "".($account_set['G_R'] == 1982 ? "selected='selected'" : NULL)."";?> >1982</option>
<option value="1981" <?ECHO "".($account_set['G_R'] == 1981 ? "selected='selected'" : NULL)."";?> >1981</option>
<option value="1980" <?ECHO "".($account_set['G_R'] == 1980 ? "selected='selected'" : NULL)."";?> >1980</option>
<option value="1979" <?ECHO "".($account_set['G_R'] == 1979 ? "selected='selected'" : NULL)."";?> >1979</option>
<option value="1978" <?ECHO "".($account_set['G_R'] == 1978 ? "selected='selected'" : NULL)."";?> >1978</option>
<option value="1977" <?ECHO "".($account_set['G_R'] == 1977 ? "selected='selected'" : NULL)."";?> >1977</option>
<option value="1976" <?ECHO "".($account_set['G_R'] == 1976 ? "selected='selected'" : NULL)."";?> >1976</option>
<option value="1975" <?ECHO "".($account_set['G_R'] == 1975 ? "selected='selected'" : NULL)."";?> >1975</option>
<option value="1974" <?ECHO "".($account_set['G_R'] == 1974 ? "selected='selected'" : NULL)."";?> >1974</option>
<option value="1973" <?ECHO "".($account_set['G_R'] == 1973 ? "selected='selected'" : NULL)."";?> >1973</option>
<option value="1972" <?ECHO "".($account_set['G_R'] == 1972 ? "selected='selected'" : NULL)."";?> >1972</option>
<option value="1971" <?ECHO "".($account_set['G_R'] == 1971 ? "selected='selected'" : NULL)."";?> >1971</option>
<option value="1970" <?ECHO "".($account_set['G_R'] == 1970 ? "selected='selected'" : NULL)."";?> >1970</option>
<option value="1969" <?ECHO "".($account_set['G_R'] == 1969 ? "selected='selected'" : NULL)."";?> >1969</option>
<option value="1968" <?ECHO "".($account_set['G_R'] == 1968 ? "selected='selected'" : NULL)."";?> >1968</option>
<option value="1967" <?ECHO "".($account_set['G_R'] == 1967 ? "selected='selected'" : NULL)."";?> >1967</option>
<option value="1966" <?ECHO "".($account_set['G_R'] == 1966 ? "selected='selected'" : NULL)."";?> >1966</option>
<option value="1965" <?ECHO "".($account_set['G_R'] == 1965 ? "selected='selected'" : NULL)."";?> >1965</option>
<option value="1964" <?ECHO "".($account_set['G_R'] == 1964 ? "selected='selected'" : NULL)."";?> >1964</option>
<option value="1963" <?ECHO "".($account_set['G_R'] == 1963 ? "selected='selected'" : NULL)."";?> >1963</option>
<option value="1962" <?ECHO "".($account_set['G_R'] == 1962 ? "selected='selected'" : NULL)."";?> >1962</option>
<option value="1961" <?ECHO "".($account_set['G_R'] == 1961 ? "selected='selected'" : NULL)."";?> >1961</option>
<option value="1960" <?ECHO "".($account_set['G_R'] == 1960 ? "selected='selected'" : NULL)."";?> >1960</option>
<option value="1959" <?ECHO "".($account_set['G_R'] == 1959 ? "selected='selected'" : NULL)."";?> >1959</option>
<option value="1958" <?ECHO "".($account_set['G_R'] == 1958 ? "selected='selected'" : NULL)."";?> >1958</option>
<option value="1957" <?ECHO "".($account_set['G_R'] == 1957 ? "selected='selected'" : NULL)."";?> >1957</option>
<option value="1956" <?ECHO "".($account_set['G_R'] == 1956 ? "selected='selected'" : NULL)."";?> >1956</option>
<option value="1955" <?ECHO "".($account_set['G_R'] == 1955 ? "selected='selected'" : NULL)."";?> >1955</option>
<option value="1954" <?ECHO "".($account_set['G_R'] == 1954 ? "selected='selected'" : NULL)."";?> >1954</option>
<option value="1953" <?ECHO "".($account_set['G_R'] == 1953 ? "selected='selected'" : NULL)."";?> >1953</option>
<option value="1952" <?ECHO "".($account_set['G_R'] == 1952 ? "selected='selected'" : NULL)."";?> >1952</option>
<option value="1951" <?ECHO "".($account_set['G_R'] == 1951 ? "selected='selected'" : NULL)."";?> >1951</option>
<option value="1950" <?ECHO "".($account_set['G_R'] == 1950 ? "selected='selected'" : NULL)."";?> >1950</option>
</select><br /><br />
  
<?
  
ECHO "<b>".LG('Пол')."</b>:<br />";
ECHO "<select name='sex' class='form-control-select' style='width: 100px;'>
<option value='1' ".($account['SEX'] == 1 ? "selected='selected'" : NULL).">".LG('Мужской')."</option>
<option value='2' ".($account['SEX'] == 2 ? "selected='selected'" : NULL).">".LG('Женский')."</option>    
</select><br /><br />"; 

HTML::BUTTON('btn-big ajax-button', 'ok', 'save', 'Сохранить изменения');

ECHO "</form>";

ECHO "</div>";

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 "<a href='/users/profile/?path=form&id=".$account['ID']."'>".LG('Личная информация')."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "".LG('Общая информация')."";
ECHO "</div>";
  
?>