<?php
  ///////////////////////////////////////////////////
  //2007 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if(is_file ("../lang/".$lang."/".$lang.".php")) include "../lang/".$lang."/".$lang.".php";
     else include "../lang/ru/ru.php";

  $title=$titlepage = $TEXT['usr-title2'];
  $helppage = $TEXT['usr-help2'];

  require_once "../config.php";
  require_once "../util/top.php";

  if($result2['master'] == 1) puterror2($TEXT['error-loginform4']);
  if($result2['manager'] == 1) puterror2($TEXT['error-loginform4']);

  if(!isset($title)) $title = $TEXT['usr-title2'];
  if(!isset($button)) $button = $TEXT['btn_add'];
  if(!isset($action)) $action = "add.php";
  if(!isset($showhide)) $visible = "checked";

  if(empty($_POST['familiya'])) $_POST['familiya'] = "";
  if(empty($_POST['name'])) $_POST['name'] = "";
  if(empty($_POST['otchestvo'])) $_POST['otchestvo'] = "";
  if(empty($_POST['mail'])) $_POST['mail'] = "";

  if(strlen($_POST['familiya'])>200) puterror2($TEXT['error-user12']);
  if(strlen($_POST['name'])>200) puterror2($TEXT['error-user14']);
  if(strlen($_POST['otchestvo'])>200) puterror2($TEXT['error-user15']);
  if(strlen($_POST['mail'])>220) puterror2($TEXT['error-user18']);
  $_POST['familiya'] = rep($_POST['familiya']);
  $_POST['name'] = rep($_POST['name']);
  $_POST['otchestvo'] = rep($_POST['otchestvo']);
  $_POST['mail'] = rep($_POST['mail']);

  $mail=$_GET['mail'];
  $name=$_GET['name'];
  $familiya=$_GET['familiya'];
  $otchestvo=$_GET['otchestvo'];
?>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-lastname']; ?></td><td class="useraddedit"><input size=50 maxlength=50 class="inputmandatory" type=text name=familiya value='<?php echo $familiya; ?>' /></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-name']; ?></td><td class="useraddedit"><input size=50 maxlength=50 class="inputmandatory" type=text name=name value='<?php echo $name; ?>' /></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-otch']; ?></td><td class="useraddedit"><input size=50 maxlength=50 type=text name=otchestvo value='<?php echo $otchestvo; ?>' /></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-pho']; ?></td><td class="useraddedit"><input type=file name=photo /></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['photo_obr']; ?></td><td>
    <select name="photo_obr">
  <option value='1' selected><?php echo $TEXT['photo_no']; ?>
  <option value='2' ><?php echo $TEXT['photo_rec_l']; ?>
  <option value='4' ><?php echo $TEXT['photo_rec_l_t']; ?>
    </select>
   </td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-position']; ?></td><td class="useraddedit"><input size=5 maxlength=5 class="inputmandatory" type=text name=position /></td></tr>
<tr><td class="useraddedit"><a href="user_translit.php" title="<?php echo $TEXT['btn_gen']; ?>" target=_blank><?php echo $TEXT['res-field4']; ?></a></td><td class="useraddedit"><input size=20 maxlength=55 class="input" type=text name=mail value='<?php echo $mail; ?>' />@
<select class="input" name="dom_id">
    <?php
        $query = "SELECT * FROM `tbl_domain` ORDER BY domain";
        $domain_tmp = mysql_query($query);
          if(!$domain_tmp) puterror2($TEXT['error-tbl5']);
              while($domain = mysql_fetch_array($domain_tmp,MYSQL_ASSOC))
                {
		 $chk = "<option value=".$domain['dom_id'].">".$domain['domain']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['usr-field1']; ?></td><td class="useraddedit"><input size=30 maxlength=30 type=text name=phone_mob  /></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['usr-field2']; ?></td><td class="useraddedit"><input size=30 maxlength=30 type=text name=phone_city  /></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['usr-field3']; ?></td><td class="useraddedit"><input size=20 maxlength=20 type=text name=phone_int  /></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-city']; ?></td>
    <td class="useraddedit"><select class="input" name="city_id">
    <?php
        $query1 = "SELECT * FROM `tbl_city` ORDER BY city";
        $city_tmp = mysql_query($query1);
          if(!$city_tmp) puterror2($TEXT['error-tbl1']);
              while($city = mysql_fetch_array($city_tmp,MYSQL_ASSOC))
                {
		$chk = "<option value=".$city['city_id'].">".$city['city']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-str']; ?></td>
    <td class="useraddedit"><select class="input" name="str_id">
    <?php
        $query2 = "SELECT * FROM `tbl_street` ORDER BY street";
        $street_tmp = mysql_query($query2);
          if(!$street_tmp) puterror2($TEXT['error-tbl3']);
              while($street = mysql_fetch_array($street_tmp,MYSQL_ASSOC))
                {
                 $chk = "<option value=".$street['str_id'].">".$street['street']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-house']; ?></td>
    <td class="useraddedit"><select class="input" name="house_id">
    <?php
        $query3 = "SELECT * FROM `tbl_house` ORDER BY house DESC";
        $house_tmp = mysql_query($query3);
          if(!$house_tmp) puterror2($TEXT['error-tbl4']);
              while($house = mysql_fetch_array($house_tmp,MYSQL_ASSOC))
                {
                 $chk = "<option value=".$house['house_id'].">".$house['house']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['usr-field4']; ?></td><td class="useraddedit"><input size=8 maxlength=8 type=text name=room  /></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-org']; ?></td>
    <td class="useraddedit"><select class="input" name="org_id">
    <?php
        $query4 = "SELECT * FROM `tbl_organizaciya` WHERE `visible` != 'hide' ORDER BY position";
        $organizaciya_tmp = mysql_query($query4);
          if(!$organizaciya_tmp) puterror2($TEXT['error-tbl7']);
              while($organizaciya = mysql_fetch_array($organizaciya_tmp,MYSQL_ASSOC))
                {
                 $chk = "<option value=".$organizaciya['org_id'].">".$organizaciya['organizaciya']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-upr']; ?></td>
    <td class="useraddedit"><select class="input" name="upr_id">
    <?php
        $query5 = "SELECT * FROM `tbl_upravlenie` ORDER BY upravlenie, position";
        $upravlenie_tmp = mysql_query($query5);
          if(!$upravlenie_tmp) puterror2($TEXT['error-tbl9']);
              while($upravlenie = mysql_fetch_array($upravlenie_tmp,MYSQL_ASSOC))
                {
                 $chk = "<option value=".$upravlenie['upr_id'].">".$upravlenie['upravlenie']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-otd']; ?></td>
    <td class="useraddedit"><select class="input" name="otd_id">
    <?php
        $query6 = "SELECT * FROM `tbl_otdel` ORDER BY otdel, position";
        $otdel_tmp = mysql_query($query6);
          if(!$otdel_tmp) puterror2($TEXT['error-tbl8']);
              while($otdel = mysql_fetch_array($otdel_tmp,MYSQL_ASSOC))
                {
                 $chk = "<option value=".$otdel['otd_id'].">".$otdel['otdel']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-post']; ?></td>
    <td class="useraddedit"><select class="input" name="dol_id">
    <?php
        $query7 = "SELECT * FROM `tbl_dolzhnost` ORDER BY dolzhnost, position";
        $dolzhnost_tmp = mysql_query($query7);
          if(!$dolzhnost_tmp) puterror2($TEXT['error-tbl6']);
              while($dolzhnost = mysql_fetch_array($dolzhnost_tmp,MYSQL_ASSOC))
                {
                 $chk = "<option value=".$dolzhnost['dol_id'].">".$dolzhnost['dolzhnost']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['usr-field5']; ?></td><td><input type=checkbox name=subscribe /></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-show']; ?></td><td><input type=checkbox name=visible <?php echo $visible; ?> /></td></tr>
<tr><td></td><td><input class="button" type=submit value='<?php echo $button; ?>' /></td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>