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

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

  $title=$titlepage=$TEXT['global-search-ext'];

  require_once "config.php";
  require_once "utils/top_search_ext.php";

  if(!isset($title)) $title = $TEXT['global-search-ext'];
  if(!isset($button)) $button = $TEXT['search-btn'];
  if(!isset($action)) $action = "search_ext_result.php";
?>
<table class="table" border="0" cellpadding="5" cellspacing="1" width="87%">
<tr class="about"><td width="43%"><?php echo $TEXT['search-descr3']; ?></td><td width="43%"><a href='allusers.php?org_id=<?php echo $_GET['org_id']; ?>' title = '<?php echo $TEXT['top2-all-users']; ?>'><?php echo $TEXT['what-all-users']; ?></a></td></tr>
</table>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-name2']; ?></td>
    <td class="tbllft" align="left"><input size=30 maxlength=50 type=text name=familiya title="<?php echo $TEXT['search-name2']; ?>"></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-name']; ?></td>
    <td class="tbllft" align="left"><input size=30 maxlength=50 type=text name=nam title="<?php echo $TEXT['search-name']; ?>"></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-otch']; ?></td>
    <td class="tbllft" align="left"><input size=30 maxlength=50 type=text name=otch title="<?php echo $TEXT['search-otch']; ?>"></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-room']; ?></td>
    <td class="tbllft" align="left"><input size=30 maxlength=16 type=text name=room title="<?php echo $TEXT['search-room']; ?>"></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['user-tel-mob']; ?></td>
    <td class="tbllft" align="left"><input size=30 maxlength=30 type=text name=mobphone title="<?php echo $TEXT['user-tel-mob']; ?>"></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['user-tel-city']; ?></td>
    <td class="tbllft" align="left"><input size=30 maxlength=30 type=text name=cityphone title="<?php echo $TEXT['user-tel-city']; ?>"></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-int-phone']; ?></td>
    <td class="tbllft" align="left"><input size=30 maxlength=20 type=text name=intphone title="<?php echo $TEXT['search-int-phone']; ?>"></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-mail']; ?></td>
    <td class="tbllft" align="left"><input size=30 maxlength=55 type=text name=mail title="<?php echo $TEXT['search-mail']; ?>"></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-mail-dom']; ?></td>
    <td class="tbllft"><select class="input" name="dom_id">
    <?php
        $query = "SELECT * FROM `tbl_domain` ORDER BY domain ";
        $domain_tmp = mysql_query($query);
          if(!$domain_tmp) puterror($TEXT['error-tbl5']);
              while($domain = mysql_fetch_array($domain_tmp,MYSQL_ASSOC))
                {
                 if($domain['dom_id'] == $dom_id)
                   {
                   $chk = "selected";
                   }
                 else $chk = "";
                 echo "<option ".$chk."value=".$domain['dom_id'].">".$domain['domain']."";
                }
    ?>
    </select></td><td><input type=checkbox name=old_dom <?php echo $visible_domain; ?>></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-city']; ?></td>
    <td class="tbllft"><select class="input" name="city_id">
    <?php
        $query1 = "SELECT * FROM `tbl_city` ORDER BY city ";
        $city_tmp = mysql_query($query1);
          if(!$city_tmp) puterror($TEXT['error-tbl1']);
              while($city = mysql_fetch_array($city_tmp,MYSQL_ASSOC))
                {
                 if($city['city_id'] == $city_id)
                   {
                   $chk = "selected";
                   }
                 else $chk = "";
                 echo "<option ".$chk."value=".$city['city_id'].">".$city['city']."";
                }
    ?>
    </select></td><td><input type=checkbox name=old_city <?php echo $visible_city; ?>></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-street']; ?></td>
    <td class="tbllft"><select class="input" name="str_id">
    <?php
        $query2 = "SELECT * FROM `tbl_street` ORDER BY street ";
        $street_tmp = mysql_query($query2);
          if(!$street_tmp) puterror($TEXT['error-tbl3']);
              while($street = mysql_fetch_array($street_tmp,MYSQL_ASSOC))
                {
                 if($street['str_id'] == $str_id)
                   {
                   $chk = "selected";
                   }
                 else $chk = "";
                 echo "<option ".$chk."value=".$street['str_id'].">".$street['street']."";
                }
    ?>
    </select></td><td><input type=checkbox name=old_str <?php echo $visible_street; ?>></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-home']; ?></td>
    <td class="tbllft"><select class="input" name="house_id">
    <?php
        $query3 = "SELECT * FROM `tbl_house` ORDER BY house ";
        $house_tmp = mysql_query($query3);
          if(!$house_tmp) puterror($TEXT['error-tbl4']);
              while($house = mysql_fetch_array($house_tmp,MYSQL_ASSOC))
                {
                 if($house['house_id'] == $house_id)
                   {
                   $chk = "selected";
                   }
                 else $chk = "";
                 echo "<option ".$chk."value=".$house['house_id'].">".$house['house']."";
                }
    ?>
    </select></td><td><input type=checkbox name=old_house <?php echo $visible_house; ?>></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-org']; ?></td>
    <td class="tbllft"><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) puterror($TEXT['error-tbl7']);
              while($organizaciya = mysql_fetch_array($organizaciya_tmp,MYSQL_ASSOC))
                {
                 if($organizaciya['org_id'] == $org_id)
                   {
                   $chk = "selected";
                   }
                 else $chk = "";
                 echo "<option ".$chk."value=".$organizaciya['org_id'].">".$organizaciya['organizaciya']."";
                }
    ?>
    </select></td><td><input type=checkbox name=old_org <?php echo $visible_organizaciya; ?>></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-upr']; ?></td>
    <td class="tbllft"><select class="input" name="upr_id">
    <?php
        $query5 = "SELECT * FROM `tbl_upravlenie` WHERE `visible` != 'hide' ORDER BY position ";
        $upravlenie_tmp = mysql_query($query5);
          if(!$upravlenie_tmp) puterror($TEXT['error-tbl9']);
              while($upravlenie = mysql_fetch_array($upravlenie_tmp,MYSQL_ASSOC))
                {
                 if($upravlenie['upr_id'] == $upr_id)
                   {
                   $chk = "selected";
                   }
                 else $chk = "";
                 echo "<option ".$chk."value=".$upravlenie['upr_id'].">".$upravlenie['upravlenie']."";
                }
    ?>
    </select></td><td><input type=checkbox name=old_upr <?php echo $visible_upravlenie; ?>></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-otd']; ?></td>
    <td class="tbllft"><select class="input" name="otd_id">
    <?php
        $query6 = "SELECT * FROM `tbl_otdel` WHERE `visible` != 'hide' ORDER BY position ";
        $otdel_tmp = mysql_query($query6);
          if(!$otdel_tmp) puterror($TEXT['error-tbl8']);
              while($otdel = mysql_fetch_array($otdel_tmp,MYSQL_ASSOC))
                {
                 if($otdel['otd_id'] == $otd_id)
                   {
                   $chk = "selected";
                   }
                 else $chk = "";
                 echo "<option ".$chk."value=".$otdel['otd_id'].">".$otdel['otdel']."";
                }
    ?>
    </select></td><td><input type=checkbox name=old_otd <?php echo $visible_otdel; ?>></td></tr>
<tr><td class="tbllft" align="right"><?php echo $TEXT['search-dol']; ?></td>
    <td class="tbllft"><select class="input" name="dol_id">
    <?php
        $query7 = "SELECT * FROM `tbl_dolzhnost` ORDER BY position ";
        $dolzhnost_tmp = mysql_query($query7);
          if(!$dolzhnost_tmp) puterror($TEXT['error-tbl6']);
              while($dolzhnost = mysql_fetch_array($dolzhnost_tmp,MYSQL_ASSOC))
                {
                 if($dolzhnost['dol_id'] == $dol_id)
                   {
                   $chk = "selected";
                   }
                 else $chk = "";
                 echo "<option ".$chk."value=".$dolzhnost['dol_id'].">".$dolzhnost['dolzhnost']."";
                }
    ?>
    </select></td><td><input type=checkbox name=old_dol <?php echo $visible_dolzhnost; ?> /></td></tr>
<tr><td></td><td><input class="button" type=submit value='<?php echo $button; ?>' /></td></tr>
</table>
</form>
<?php
  require_once "utils/bottom_search.php";
?>