<?php


function USERS_COLUMN_INIT() {
	SEF("USERS_FIELDS_PROFILE_INIT");
	USERS_FIELDS_PROFILE_INIT();
	return; // TODO: test on BIALL-NET

global $result,$USERS_COLUMN,$USERSHIST_COLUMN;

$ARG1="GENERATE";

// load user profile (hidden column)
ZAP_SQL("select `ADM_WWW_PROFILE` from `ADMIN_USERS` where `ADM_ACCOUNT`='".$_SESSION['ADM_ACCOUNT']."' limit 0,1 ");
while ($h = mysql_fetch_object($result)) {
	$ADM_WWW_PROFILE = "$h->ADM_WWW_PROFILE";
	//echo "<HR>$ADM_WWW_PROFILE WWW-PROFILE**********<BR>";
	eval("\$_SESSION['USER_PROFILE'] = $ADM_WWW_PROFILE ;");
}

SEF("USERS_FIELDS_PROFILE_PRE_INIT");
USERS_FIELDS_PROFILE_PRE_INIT();// include ['RELATIVEDB']['SQL_QUERY']

ZAP_SQL("show fields from ADMIN_USERS");
//echo "<HR>";
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION['ADMIN_COLUMN']['DESC']["$KEY"] = $h[0];
 $_SESSION['ADMIN_COLUMN']['DESC_TO_KEY'][$h[0]] = $KEY;
if(!isset($_SESSION['ADMIN_COLUMN']['PERMEDIT'][$h[0]])) $_SESSION['ADMIN_COLUMN']['PERMEDIT'][$h[0]] = "N" ;
  $_SESSION['ADMIN_COLUMN']['ID']["$KEY"]=$KEY;
$TEMP1=$_SESSION['ADMIN_COLUMN']['DESC']["$KEY"];
 $_SESSION['ADMIN_COLUMN']['TYPE'][$_SESSION['ADMIN_COLUMN']['DESC']["$KEY"]] = $h[1];
if(isset($_SESSION['USER_PROFILE']['ADMIN_COLUMN']["$KEY"]) && $_SESSION['USER_PROFILE']['ADMIN_COLUMN']["$KEY"] == "HIDE") {
    $_SESSION['ADMIN_COLUMN']['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }

ZAP_SQL("show fields from ADMIN_USERS");
//echo "<HR>";
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION['ADMIN2_COLUMN']['DESC']["$KEY"] = $h[0];
 $_SESSION['ADMIN2_COLUMN']['DESC_TO_KEY'][$h[0]] = $KEY;
if(!isset($_SESSION['ADMIN2_COLUMN']['PERMEDIT'][$h[0]])) $_SESSION['ADMIN2_COLUMN']['PERMEDIT'][$h[0]] = "N" ;
  $_SESSION['ADMIN2_COLUMN']['ID']["$KEY"]=$KEY;
$TEMP1=$_SESSION['ADMIN2_COLUMN']['DESC']["$KEY"];
 $_SESSION['ADMIN2_COLUMN']['TYPE'][$_SESSION['ADMIN2_COLUMN']['DESC']["$KEY"]] = $h[1];
if(isset($_SESSION['USER_PROFILE']['ADMIN_COLUMN']["$KEY"]) && $_SESSION['USER_PROFILE']['ADMIN_COLUMN']["$KEY"] == "HIDE") {
    $_SESSION['ADMIN2_COLUMN']['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }




ZAP_SQL("show fields from USERS2");
$EXTRACOLUMN="P_NAME_R M_REWIR";
$EXTRACOLUMN = explode(" ", $EXTRACOLUMN);


 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION['USERS2_COLUMN']['DESC']["$KEY"] = $h[0];
 $_SESSION['USERS2_COLUMN']['DESC_TO_KEY'][$h[0]] = $KEY;
if(!isset($_SESSION['USERS2_COLUMN']['PERMEDIT'][$h[0]])) $_SESSION['USERS2_COLUMN']['PERMEDIT'][$h[0]] = "N" ;
  $_SESSION['USERS2_COLUMN']['ID']["$KEY"]=$KEY;
$TEMP1=$_SESSION['USERS2_COLUMN']['DESC']["$KEY"];
 $_SESSION['USERS2_COLUMN']['TYPE'][$_SESSION['USERS2_COLUMN']['DESC']["$KEY"]] = $h[1];
if(isset($_SESSION['USER_PROFILE']['USERS2_COLUMN']["$KEY"]) && $_SESSION['USER_PROFILE']['USERS2_COLUMN']["$KEY"] == "HIDE") {
    $_SESSION['USERS2_COLUMN']['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }
  foreach ($EXTRACOLUMN as $h) {
 $_SESSION['USERS2_COLUMN']['DESC']["$KEY"] = $h;
 $_SESSION['USERS2_COLUMN']['DESC_TO_KEY'][$h] = $KEY;
if(!isset($_SESSION['USERS2_COLUMN']['PERMEDIT'][$h])) $_SESSION['USERS2_COLUMN']['PERMEDIT'][$h] = "N" ;
  $_SESSION['USERS2_COLUMN']['ID']["$KEY"]=$KEY;
$TEMP1=$_SESSION['USERS2_COLUMN']['DESC']["$KEY"];
 $_SESSION['USERS2_COLUMN']['TYPE'][$_SESSION['USERS2_COLUMN']['DESC']["$KEY"]] = "varchar(245)";
if(isset($_SESSION['USER_PROFILE']['USERS2_COLUMN']["$KEY"]) && $_SESSION['USER_PROFILE']['USERS2_COLUMN']["$KEY"] == "HIDE") {
    $_SESSION['USERS2_COLUMN']['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }





ZAP_SQL("show fields from DEVICES");
//echo "<HR>";
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION['DEVICES_COLUMN']['DESC'][$KEY] = $h[0];
 $_SESSION['DEVICES_COLUMN']['DESC_TO_KEY'][$h[0]] = $KEY;
if(!isset($_SESSION['DEVICES_COLUMN']['PERMEDIT'][$h[0]])) $_SESSION['DEVICES_COLUMN']['PERMEDIT'][$h[0]] = "N" ;
  $_SESSION['DEVICES_COLUMN']['ID'][$KEY]=$KEY;
$TEMP1=$_SESSION['DEVICES_COLUMN']['DESC'][$KEY];
 $_SESSION['DEVICES_COLUMN']['TYPE'][$_SESSION['DEVICES_COLUMN']['DESC'][$KEY]] = $h['1'];
if(isset($_SESSION['USER_PROFILE']['DEVICES_COLUMN'][$KEY]) && $_SESSION['USER_PROFILE']['DEVICES_COLUMN'][$KEY] == "HIDE") {
    $_SESSION['DEVICES_COLUMN']['HIDE'][$KEY]='HIDE';
    }
//if(isset($_COOKIE[COOKIE_DEVICES_COLUMN][INDEX]["$KEY"])) $_SESSION['DEVICES_COLUMN'][INDEX]["$KEY"] = $_COOKIE[COOKIE_DEVICES_COLUMN][INDEX]["$KEY"];
  $KEY++;
  }



ZAP_SQL("show fields from USERS2_HIST");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
//  print "<BR>" . $h[0] . $KEY ;
 $_SESSION['USERS2_HIST_COLUMN']['DESC']["$KEY"] = $h[0];
 $_SESSION['USERS2_HIST_COLUMN']['DESC_TO_KEY'][$h[0]] = $KEY;
if(!isset($_SESSION['USERS2_HIST_COLUMN']['PERMEDIT'][$h[0]])) $_SESSION['USERS2_HIST_COLUMN']['PERMEDIT'][$h[0]] = "R" ;
  $_SESSION['USERS2_HIST_COLUMN']['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE']['USERS2_HIST_COLUMN']["$KEY"]) && $_SESSION['USER_PROFILE']['USERS2_HIST_COLUMN']["$KEY"] == "HIDE") {
    $_SESSION['USERS2_HIST_COLUMN']['HIDE']["$KEY"]='HIDE';
    }
//if(isset($_COOKIE[COOKIE_USERS_COLUMN][INDEX]["$KEY"])) $_SESSION['USERS2_HIST_COLUMN'][INDEX]["$KEY"] = $_COOKIE[COOKIE_USERS_COLUMN][INDEX]["$KEY"];
  $KEY++;
  }



ZAP_SQL("show fields from DEVICES_HIST");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION['DEVICES_HIST_COLUMN']['DESC']["$KEY"] = $h[0];
 $_SESSION['DEVICES_HIST_COLUMN']['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION['DEVICES_HIST_COLUMN']['ID']["$KEY"]=$KEY;
if(!isset($_SESSION['DEVICES_HIST_COLUMN']['PERMEDIT'][$h[0]])) $_SESSION['DEVICES_HIST_COLUMN']['PERMEDIT'][$h[0]] = "R" ;
if(isset($_SESSION['USER_PROFILE']['DEVICES_HIST_COLUMN']["$KEY"]) && $_SESSION['USER_PROFILE']['DEVICES_HIST_COLUMN']["$KEY"] == "HIDE") {
    $_SESSION['DEVICES_HIST_COLUMN']['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }




ZAP_SQL("show fields from BUILDINGS");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION['BUILDINGS_COLUMN']['DESC']["$KEY"] = $h[0];
 $_SESSION['BUILDINGS_COLUMN']['TYPE'][$_SESSION['BUILDINGS_COLUMN']['DESC']["$KEY"]] = $h[1];
 $_SESSION['BUILDINGS_COLUMN']['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION['BUILDINGS_COLUMN']['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE']['BUILDINGS_COLUMN']["$KEY"]) && $_SESSION['USER_PROFILE']['BUILDINGS_COLUMN']["$KEY"] == "HIDE") {
    $_SESSION['BUILDINGS_COLUMN']['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }



ZAP_SQL("show fields from EXTRA_SERVICES");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION['EXTRA_SERVICES_COLUMN']['DESC']["$KEY"] = $h[0];
 $_SESSION['EXTRA_SERVICES_COLUMN']['TYPE'][$_SESSION['EXTRA_SERVICES_COLUMN']['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION['EXTRA_SERVICES_COLUMN']['PERMEDIT'][$h[0]])) $_SESSION['EXTRA_SERVICES_COLUMN']['PERMEDIT'][$h[0]] = "RW" ;
 $_SESSION['EXTRA_SERVICES_COLUMN']['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION['EXTRA_SERVICES_COLUMN']['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE']['EXTRA_SERVICES_COLUMN']["$KEY"]) && $_SESSION['USER_PROFILE']['EXTRA_SERVICES_COLUMN']["$KEY"] == "HIDE") {
    $_SESSION['EXTRA_SERVICES_COLUMN']['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }



ZAP_SQL("show fields from NETWORKS_SERVERS");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION['NETWORKS_SERVERS_COLUMN']['DESC']["$KEY"] = $h[0];
 $_SESSION['NETWORKS_SERVERS_COLUMN']['TYPE'][$_SESSION['NETWORKS_SERVERS_COLUMN']['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION['NETWORKS_SERVERS_COLUMN']['PERMEDIT'][$h[0]])) $_SESSION['NETWORKS_SERVERS_COLUMN']['PERMEDIT'][$h[0]] = "RW" ;
 $_SESSION['NETWORKS_SERVERS_COLUMN']['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION['NETWORKS_SERVERS_COLUMN']['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE']['NETWORKS_SERVERS_COLUMN']["$KEY"]) && $_SESSION['USER_PROFILE']['NETWORKS_SERVERS_COLUMN']["$KEY"] == "HIDE") {
    $_SESSION['NETWORKS_SERVERS_COLUMN']['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }

$COLUMN="USERS2_DEALS";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "RX" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }

$COLUMN="USERS2_DEALS_HIST";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }



$COLUMN="SES_SERWIS_A";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "RW" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }



$COLUMN="BUILDINGS_HIST";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }


$COLUMN="KSIEG_DOKUMENTY_HIST";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }



$COLUMN="USERS2_MARKETING";
$EXTRACOLUMN="INTERNET_STATUS ";
$EXTRACOLUMN = explode(" ", $EXTRACOLUMN);

//TODO2006-03 zapytanie w foreach
//inicjalizacja podrecznikowych zapytan do tabel dla jednej sesji
if($_SESSION['USERS2_MARKETING_COLUMN']['RELATIVEDB']['SQL_QUERY'][1]) {
foreach($_SESSION['USERS2_MARKETING_COLUMN']['RELATIVEDB']['SQL_QUERY'] as $value_key => $value) {
 // echo "<br> Zainicjalizowano! zapytanie key $value_key value $value   <br> ";
 ZAP_SQL($value);
  }
 }
ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "RWXC" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }
  foreach ($EXTRACOLUMN as $h) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h] = $KEY;
if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h] = "N" ;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
$TEMP1=$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = "varchar(245)";
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }


$COLUMN="USERS2_MARKETING_HIST";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "RW" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }


//2007-10-31 added by SQIX columns for Marketing Offers Overwiev  USERS2_OFFERS


$COLUMN="USERS2_OFFERS";
//$EXTRACOLUMN="INTERNET_STATUS ";
//$EXTRACOLUMN = explode(" ", $EXTRACOLUMN);

//TODO2006-03 zapytanie w foreach
//inicjalizacja podrecznikowych zapytan do tabel dla jednej sesji
if(isset($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'][1])) {
foreach($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'] as $value_key => $value) {
// echo "<br> Zainicjalizowano zapytanie value $value key $value_key <br> ";
 ZAP_SQL($value);
  }
 }
ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "RWXC" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }
  foreach ($EXTRACOLUMN as $h) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h] = $KEY;
if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h] = "N" ;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
$TEMP1=$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = "varchar(245)";
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }



$COLUMN="USERS2_OFFERS_HIST";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }



$COLUMN="USERS2_WINDYKACJA";
$EXTRACOLUMN="P_NAME_R P_ADDRESS_R";
$EXTRACOLUMN = explode(" ", $EXTRACOLUMN);

//TODO2006-03 zapytanie w foreach
//inicjalizacja podrecznikowych zapytan do tabel dla jednej sesji
if(isset($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'][1])) {
foreach($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'] as $value_key => $value) {
// echo "<br> Zainicjalizowano zapytanie value $value key $value_key <br> ";
 ZAP_SQL($value);
  }
 }
ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "RWXC" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }
  foreach ($EXTRACOLUMN as $h) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h] = $KEY;
if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h] = "N" ;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
$TEMP1=$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = "varchar(245)";
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }



$COLUMN="USERS2_WINDYKACJA_HIST";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }







$COLUMN="USERS2_MARKETING_OVERWIEV";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }




$COLUMN="USERS2_MARKETING_OVERWIEV_REWIR";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }



$COLUMN="KSIEG_DOKUMENTY";
if($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'][1]) {
foreach($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'] as $value_key => $value) {
// echo "<br> Zainicjalizowano zapytanie value $value key $value_key <br> ";
 ZAP_SQL($value);
  }
 }
ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }

$COLUMN="CRM_LISTA_ZASOBOW";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }

$COLUMN="IN7_MK_BAZA_DYSTRYBUCJI";
//$EXTRACOLUMN="PODSUMOWANIE ";
//$EXTRACOLUMN = explode(" ", $EXTRACOLUMN);
//$EXTRACOLUMN = explode($EXTRACOLUMN, " ");

//TODO2006-03 zapytanie w foreach
//inicjalizacja podrecznikowych zapytan do tabel dla jednej sesji
if($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'][1]) {
foreach($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'] as $value_key => $value) {
// echo "<br> Zainicjalizowano zapytanie value $value key $value_key <br> ";
 ZAP_SQL($value);
  }
 }
ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }
  foreach ($EXTRACOLUMN as $h) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h] = $KEY;
if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h] = "N" ;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
$TEMP1=$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = "varchar(245)";
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }

// HIDE field M_DIST_DESC_HTML by default
$_SESSION[$COLUMN."_COLUMN"]['HIDE'][ $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY']['M_DIST_DESC_HTML'] ] = 'HIDE';


$COLUMN="IN7_MK_BAZA_DYSTRYBUCJI_HIST";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "RW" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }

//EOF DEKLARACJA PRZYKLADOWA KOLUMNY 2007-10



$COLUMN="IN7_DZIENNIK_KORESP";
//$EXTRACOLUMN="PODSUMOWANIE ";
//$EXTRACOLUMN = explode(" ", $EXTRACOLUMN);
//$EXTRACOLUMN = explode($EXTRACOLUMN, " ");

//TODO2006-03 zapytanie w foreach
//inicjalizacja podrecznikowych zapytan do tabel dla jednej sesji
if(isset($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'][1])) {
foreach($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'] as $value_key => $value) {
// echo "<br> Zainicjalizowano zapytanie value $value key $value_key <br> ";
 ZAP_SQL($value);
  }
 }
ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }
  foreach ($EXTRACOLUMN as $h) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h] = $KEY;
if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h] = "N" ;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
$TEMP1=$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = "varchar(245)";
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }

$COLUMN="IN7_DZIENNIK_KORESP_HIST";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "RW" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }

//EOF DEKLARACJA PRZYKLADOWA KOLUMNY 2007-10


//2012-09-15 USERS2 normal init!!!

$COLUMN="USERS2";
$EXTRACOLUMN="P_NAME_R M_REWIR";
$EXTRACOLUMN = explode(" ", $EXTRACOLUMN);

//TODO2006-03 zapytanie w foreach
//inicjalizacja podrecznikowych zapytan do tabel dla jednej sesji
if(isset($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'][1])) {
foreach($_SESSION[$COLUMN."_COLUMN"]['RELATIVEDB']['SQL_QUERY'] as $value_key => $value) {
// echo "<br> Zainicjalizowano zapytanie value $value key $value_key <br> ";
 ZAP_SQL($value);
  }
 }
ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "R" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }
  foreach ($EXTRACOLUMN as $h) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h] = $KEY;
if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h] = "N" ;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
$TEMP1=$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = "varchar(245)";
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }

$COLUMN=$COLUMN."_HIST";

ZAP_SQL("show fields from $COLUMN");
 $KEY=0;
  while ($h=mysql_fetch_row($result)) {
 $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
 $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
 if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "RW" ;
 $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
if(isset($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"]) && $_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
    $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
    }
  $KEY++;
  }




//EOF DEKLARACJA PRZYKLADOWA KOLUMNY 2007-10





// VOIP
SEF('USERS_COLUMN_INIT2');
USERS_COLUMN_INIT2('VOIP_CENNIK','','RWXC');
USERS_COLUMN_INIT2('VOIP_MAP','','RWXC');
USERS_COLUMN_INIT2('VOIP_PROMO','','RWXC');
USERS_COLUMN_INIT2('VOIP_FREE_TIME','','RWXC');

// OFFERS_COSTS
USERS_COLUMN_INIT2('USERS2_OFFERS_COSTS','TV_NAZWA_PROGRAMU','RWXC');
USERS_COLUMN_INIT2('USERS2_OFFERS_COSTS_GROUPS','','RWXC');
USERS_COLUMN_INIT2('USERS2_OFFERS_COSTS_SALES_PLAN','','RWXC');
USERS_COLUMN_INIT2('SES_USERS2_A','M_REWIR','RWXC');
USERS_COLUMN_INIT2('SES_VOIP_A','P_SERVICE_ORDERED_INSTALL_DATE_1297 P_NAME','R');
USERS_COLUMN_INIT2('SES_TV_A','P_SERVICE_ORDERED_INSTALL_DATE_1297','R');
USERS_COLUMN_INIT2('SES_DOMAINS_A','','R');

USERS_COLUMN_INIT2('SERVICES','P_NAME P_NAME_SECOND A_STATUS_CURRENT A_STATUS_LOCAL L3_SERVICE_INFO SHOW_RECORD_L3 L3_SERVICE_STATUS','R');
//USERS_COLUMN_INIT2('SERVICES','P_NAME P_NAME_SECOND A_STATUS_CURRENT','R');
USERS_COLUMN_INIT2('BILLING_USERS_ADD','L2_SERVICE_STATUS SHOW_RECORD_L2 L3_SERVICE_STATUS L3_SERVICE_INFO SHOW_RECORD_L3','R');
USERS_COLUMN_INIT2('BILLING_USERS','','R');
USERS_COLUMN_INIT2('TELBOXES','','R');


USERS_COLUMN_INIT2('RAPORT_CROSS','','RX');

//USERS_COLUMN_INIT2('USERS2_MARKETING_OVERWIEV_REWIR','','RX');


//SEF("L_APPOITMENT_RESULT");

//L_APPOITMENT_RESULT("show fields from tmp");
 //$KEY=0;
  //while ($h=mysql_fetch_row($result)) {
 //$_SESSION['L_APPOITMENT_COLUMN']['DESC']["$KEY"] = $h[0];
 //$_SESSION['L_APPOITMENT_COLUMN']['DESC_TO_KEY'][$h[0]] = $KEY;
//if(!isset($_SESSION['L_APPOITMENT_COLUMN']['PERMEDIT'][$h[0]])) $_SESSION['L_APPOITMENT_COLUMN']['PERMEDIT'][$h[0]] = "R" ;
  //$_SESSION['L_APPOITMENT_COLUMN']['ID']["$KEY"]=$KEY;
//$TEMP1=$_SESSION['L_APPOITMENT_COLUMN']['DESC']["$KEY"];
 //$_SESSION['L_APPOITMENT_COLUMN']['TYPE'][$_SESSION['L_APPOITMENT_COLUMN']['DESC']["$KEY"]] = $h[1];
//if(isset($_SESSION['USER_PROFILE']['L_APPOITMENT_COLUMN']["$KEY"]) && $_SESSION['USER_PROFILE']['L_APPOITMENT_COLUMN']["$KEY"] == "HIDE") {
    //$_SESSION['L_APPOITMENT_COLUMN']['HIDE']["$KEY"]='HIDE';
    //}
  //$KEY++;
  //}

	SEF("USERS_FIELDS_PROFILE_INIT");
	USERS_FIELDS_PROFILE_INIT();
}
