<?php
  ///////////////////////////////////////////////////
  //2011 (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['alias-ed'];
  $helppage = $TEXT['tip-help-edit'];

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

  if(!isset($title)) $title = $TEXT['supp-tip-title3'];
  if(!isset($button)) $button = $TEXT['btn_edit'];
  if(!isset($action)) $action = "edit-tip.php";

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

  if(strlen($_GET['tip_id'])>11) puterror2($TEXT['error-tip4']);
  $_GET['tip_id'] = rep($_GET['tip_id']);
  $old_tip_id = $_GET['tip_id'];

  $query_tip = "SELECT * FROM `tbl_tip_resurs` WHERE `tip_id`='".$_GET['tip_id']."' ";
  $result3 = mysql_query($query_tip);
  if(!$result3) puterror2($TEXT['error-tbl38']);
   $result4 = mysql_fetch_array($result3);
         $tip_name = $result4['tip_name'];
         $position = $result4['position'];
         $old_photo = $result4['pic_tip'];
         $prefix = $result4['prefix'];
	if(!empty($result4['pic_tip'])) $picture = "<img alt='".$tip_name."'  src='../".$result4['pic_tip']."' />";
	  else $picture = $TEXT['res-field17'];
?>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="useraddedit"><?php echo $TEXT['inst-field1']; ?></td><td class="useraddedit" align=center><?php echo $picture; ?></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['inst-field6']; ?></td><td><input type=file name=photo></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-nazv']; ?></td><td><input size=30 maxlength=200 class="inputmandatory" type=text name=tip_name value='<?php echo $tip_name; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tip-pref']; ?></td><td><input size=30 maxlength=200 type=text name=prefix value='<?php echo $prefix; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['nd-field10']; ?></td><td><input size=5 maxlength=11 class="inputmandatory" type=text name=position value='<?php echo $position; ?>'></td></tr>
<tr><td></td><td>
<input class=button type=submit value='<?php echo $button; ?>' />
<input type=hidden name=tip_id value='<?php echo $old_tip_id; ?>' />
<input type=hidden name=old_photo value='<?php echo $old_photo; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>