<?php


function USERS_EDIT() {
global $thiss,$MENU_INIT,$ARG1,$ARG1_VAL,$SQL_USER,$SQL_DATABASE,$INTERFACE_ADDR,$SQL_USER_PASS,$USERS_FILTER_PROBLEM,$USERS_FILTER_STATUS,$SQL_WIEV,$USERS_COLUMN,$USERS_COLUMN_DESC,$USERS_HIDECOLUMN;
DETECT_TABLE_COLUMN();
if(($MENU_INIT == 'USERS_EDIT') && ($ARG1=="EDIT")) {
$_SESSION['USERS_COLUMN']['WIEVID']="$ARG1_VAL";
 }
SEF("MENU");
MENU();
//NAVIGATOR();
//$_SESSION[CURRENT_MENU]=USERS;
if($_SESSION['DEBUG']) echo "USERS WIEV FUNCTION USED";
if($USERS_FILTER_PROBLEM) USERS_FILTER_PROBLEM();
//SQL_WIEV();
//USERS_HIDECOLUMN();
//USERS_SORTER();
$conn=mysql_pconnect($INTERFACE_ADDR,$SQL_USER,$SQL_USER_PASS);
if (!$conn) die("ERROR podczas tworzenia polaczenia do bazy $SQL_DATABASE !\n");
mysql_select_db($SQL_DATABASE) or die("ERROR podczas wyboru bazy R50!");

//$zapSQL="SELECT * from USERS2  where A_ADM_COMPANY like '$_SESSION[ADM_COMPANY]' $_SESSION[USERS_FILTER_PROBLEM_SQL] $_SESSION[USERS_FILTER_STATUS_SQL] $_SESSION[USERS_SORTER_SQL] ;";
//echo "$zapSQL";
//$result = mysql_query($zapSQL,$conn) or die("Blad zapytania2!");
//$_SESSION[MYSQL_NUM_ROWS_TOTAL][USERS] = mysql_num_rows($result);

$zapSQL="SELECT * from USERS2  where A_ADM_COMPANY like '".$_SESSION['ADM_COMPANY']."' and ID='" . $_SESSION["USERS_COLUMN"]["WIEVID"] . "'  ;";
//echo "$zapSQL";
//$zapSQL="SELECT * from USERS2  group by S_HWSTAT ;";
//echo "$zapSQL";
$result = mysql_query($zapSQL,$conn) or die("Blad zapytania2!");
$num_rows = mysql_num_rows($result);
$_SESSION['MYSQL_NUM_ROWS'] = $num_rows;
//echo "<BR>LICZBA_WIERSZY $num_rows<BR>";
//MENU_USERS();


{
echo "\n<table width='100%' border='1' cellspacing='0' cellpadding='0'>";
    echo "<TD><font size=-2>";
    echo "</TD><TD>Nazwa_POLA";
    CREATE_MENUFUNC_INIT_2('USERS_HISTORY', 'HISTORY', $_SESSION['USERS_COLUMN']['WIEVID'], '<img src=icon/history.gif alt=HISTORIA border=0>') ;
    echo "</TD><TD>WARTOSC</TD></TR>
    <FORM ACTION='".$_SERVER['PHP_SELF']."' method=POST name=USERS_EDIT><input type=HIDDEN name=WIEVID value=".$_SESSION['USERS_COLUM']['WIEVID']."><input type=HIDDEN name=FUNCTION_INIT value=UPDATEDB>";
    while ($h=mysql_fetch_row($result)) {
    foreach ($_SESSION['USERS_COLUMN']['ID'] as $value) {
     if(!(strstr($ARG1_VAL,'RESTORE'))) $_SESSION['USERS_COLUMN']['EDIT_TEMPLATE'][$_SESSION['USERS_COLUMN']['DESC'][$value]]=$h[$value];
     $_SESSION['USERS_COLUMN']['EDITRECORD'][$_SESSION['USERS_COLUMN']['DESC'][$value]]=$h[$value];
     if(strstr($_SESSION['USERS_COLUMN']['PERMEDIT'][$_SESSION['USERS_COLUMN']['DESC'][$value]],"R")) { 
      echo "<TR><TD><font size=-2>" ;//. $_SESSION[USERS_COLUMN][PERMEDIT][$_SESSION[USERS_COLUMN][DESC][$value]];
      echo "<BR>";
      echo "</TD><TD>";
       if($_SESSION['USERS_COLUMN']['DESC_TO_LANG'][$_SESSION['USERS_COLUMN']['DESC']["$value"]]) { echo $_SESSION['USERS_COLUMN']['DESC_TO_LANG'][$_SESSION['USERS_COLUMN']['DESC']["$value"]] . "<br>";
       echo "<font size=-2>".$_SESSION["USERS_COLUMN"]["DESC"]["$value"]."</font>";
       } else echo $_SESSION["USERS_COLUMN"]["DESC"]["$value"];
      echo "</TD>";
      echo "<TD ";
      USERS_COLUMN_COLOR($_SESSION['USERS_COLUMN']['DESC'][$value], $_SESSION['USERS_COLUMN']['EDIT_TEMPLATE'][$_SESSION['USERS_COLUMN']['DESC'][$value]], 'bgcolor');
      echo ">";
      if((strstr($_SESSION['USERS_COLUMN']['PERMEDIT'][$_SESSION['USERS_COLUMN']['DESC'][$value]],'RW')) && (!isset($_SESSION['USERS_COLUMN']['TYPESPECIAL'][$_SESSION['USERS_COLUMN']['DESC'][$value]]))) {
         GETFORMITEM($_SESSION['USERS_COLUMN']['EDIT_TEMPLATE'][$_SESSION['USERS_COLUMN']['DESC'][$value]],$_SESSION['USERS_COLUMN']['TYPE'][$_SESSION['USERS_COLUMN']['DESC'][$value]],$_SESSION['USERS_COLUMN']['DESC'][$value]);
	 echo "($h[$value])"; 
       } else if(isset($_SESSION['USERS_COLUMN']['TYPESPECIAL'][$_SESSION['USERS_COLUMN']['DESC'][$value]])) {
         $_SESSION['USERS_COLUMN']['TYPESPECIAL'][$_SESSION['USERS_COLUMN']['DESC'][$value]]($_SESSION["USERS_COLUMN"]["WIEVID"],$_SESSION['USERS_COLUMN']['EDIT_TEMPLATE'][$_SESSION['USERS_COLUMN']['DESC'][$value]]);
       } else echo $_SESSION['USERS_COLUMN']['EDIT_TEMPLATE'][$_SESSION['USERS_COLUMN']['DESC'][$value]];
	echo "</td></TR>";
       }
      }

     }
    } 
//$_SESSION['USERS_COLUMN']['EDITRECORD']['TAB_UPDATE_STAT']="1"; //Olanie w historii wpisywania rekordow dotyczacych zmiany aktualizacji
echo "<tr><td colspan=3 align=center><input type=submit value='          OK          '></td></tr></form></table>";
return;
}
?>
