<?php
//session_start();
//version 2005-07-19
//+added T_WHO_CONNECTED
//+added S_HW verify and edit
//+removed problem between switching windows with APPOITMENTS_SET and added APP_DIFFERENT_SETS (sqix 2007-09-11)
//$_SESSION[DEBUG]='';
//+added 2008-02-27 TOOLBAR_DETECT function else - mozna w historii dodawac

if (!function_exists('SEF')) require_once 'superedit-SEF.php';

SEF('ZAP_SQL');
SEF('ZAP_SQL_UPDATE');
SEF("WIEVTABLE");

SEF("GETFORMITEM");

SEF('USERS_FILTERS');// USERS_FILTER_PROBLEM, USERS_FILTER_STATUS, USERS_FILTER_APPOINTMENT

SEF('ID_COSTS_GROUPS');

SEF('T_WHEN_CONNECTED');

function ECHOO($VAR) {
	echo "$VAR";
}


function NAVIGATOR() {
global $thiss,$result;
if(($thiss->DETECT_TABLE_COLUMN) && ($thiss->DETECT_TABLE_NAME)) {
if(!isset($_SESSION[$thiss->DETECT_TABLE_COLUMN]['ILE'])) $_SESSION[$thiss->DETECT_TABLE_COLUMN]['ILE']=100;
 }
if(!isset($_SESSION['ILE'])) $_SESSION_ILE=100; //TO_DELETE_VARIABLE TODO
CREATE_MENU_NOTD_INIT('SQL_WIEV', 'BEGIN', '|&lt;&lt;');
echo "&nbsp;";
CREATE_MENU_NOTD_INIT('SQL_WIEV', 'PREV', "&lt;&lt;<font size=-1>-".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['ILE']."</font>");
CREATE_MENUFUNC_NOTD_INIT('SQL_ILE_MENU', "<font size=-1>" . $_SESSION[$thiss->DETECT_TABLE_COLUMN]['SQL_WIEV_CURR']  . "</font><font size=-1> (" . $_SESSION[$thiss->DETECT_TABLE_COLUMN]['MYSQL_NUM_ROWS_TOTAL'] . ")</font>");
echo "&nbsp;";
CREATE_MENU_NOTD_INIT('SQL_WIEV', 'NEXT', "<font size=-1>+".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['ILE']."</font>&gt;&gt;");
echo "&nbsp;";
CREATE_MENU_NOTD_INIT('SQL_WIEV', 'LAST', '&gt;&gt;|');
return;
}


function SQL_ILE_MENU() {
global $thiss,$ARG1,$ARG1_VAL;
if(($thiss->DETECT_TABLE_COLUMN) && ($thiss->DETECT_TABLE_NAME)) {
echo "Wybierz sposoby nawigacji dla Kolumn ($thiss->DETECT_TABLE_COLUMN) i tabeli ($thiss->DETECT_TABLE_NAME) <table border=1 cellspacing=0 cellpadding=0><tr><td>
Ilosc Pokazywanych Rekordow</td><td>
Poczatek Nawigacji</td></tr><tr><td>";
for ($i = 1; $i < $_SESSION[$thiss->DETECT_TABLE_COLUMN]['MYSQL_NUM_ROWS_TOTAL']*2;$i=$i*2+10) {
CREATE_MENU_NOTD_INIT_3('SQL_WIEV', 'ILE', "$i", "$i");
if($_SESSION['ILE'] == $i) echo "<i>V</i>";
print "<br>";
}
echo "</td><td>";
for ($i = 0; $i < $_SESSION[$thiss->DETECT_TABLE_COLUMN]['MYSQL_NUM_ROWS_TOTAL'];$i=$i*2+10) {
CREATE_MENU_NOTD_INIT_3('SQL_WIEV', 'POSITION', "$i", "$i");
if($_SESSION['SQL_WIEV_CURR'] == $i) echo "<i>V</i>";
print "<br>";
}
echo "</td></tr></table>";
CREATE_MENUFUNC_NOTD_INIT($_SESSION['LAST_MENU'], 'POWROT<img src=icon/back.gif border=0 alt=POWROT>');

} else {

echo "Wybierz sposoby nawigacji<table border=1 cellspacing=0 cellpadding=0><tr><td>
Ilosc Pokazywanych Rekordow</td><td>
Poczatek Nawigacji</td></tr><tr><td>";
for ($i = 1; $i < $_SESSION['MYSQL_NUM_ROWS_TOTAL']['USERS']*2;$i=$i*2+10) {
CREATE_MENU_NOTD_INIT_3('SQL_WIEV', 'ILE', "$i", "$i");
if($_SESSION['ILE'] == $i) echo "<i>V</i>";
print "<br>";
}
echo "</td><td>";
for ($i = 0; $i < $_SESSION['MYSQL_NUM_ROWS_TOTAL']['USERS'];$i=$i*2+10) {
CREATE_MENU_NOTD_INIT_3('SQL_WIEV', 'POSITION', "$i", "$i");
if($_SESSION['SQL_WIEV_CURR'] == $i) echo "<i>V</i>";
print "<br>";
}
echo "</td></tr></table>";
CREATE_MENUFUNC_NOTD_INIT($_SESSION['LAST_MENU'], 'POWROT<img src=icon/back.gif border=0 alt=POWROT>');
 } //EOF else this

return;
}


SEF('SQL_WIEV');







function USERS_SORTER() {
	global $thiss;

	$USERS_SORTER = (!empty($_REQUEST['USERS_SORTER']))? $_REQUEST['USERS_SORTER'] : null;
	$USERS_SORTER1 = (!empty($_REQUEST['USERS_SORTER1']))? $_REQUEST['USERS_SORTER1'] : null;
	$USERS_SORTER2 = (!empty($_REQUEST['USERS_SORTER2']))? $_REQUEST['USERS_SORTER2'] : null;

	if ($USERS_SORTER1) {
	    SEF('RELATIVEDB_SRC_COLUMN');
		$_SESSION[$thiss->DETECT_TABLE_COLUMN]['USERS_SORTER_SQL'] = "ORDER BY ".RELATIVEDB_SRC_COLUMN($USERS_SORTER1)." DESC";
		$_SESSION['USERS_SORTER_SQL'] = "ORDER BY $USERS_SORTER1";//TODO REMOVE
		foreach ($_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC'] as $value) {
			if ($_SESSION['DEBUG']) echo "$value";
			unset($_SESSION[$thiss->DETECT_TABLE_COLUMN]['SORTED'][$value]);
		}
		$_SESSION[$thiss->DETECT_TABLE_COLUMN]['SORTED'][$USERS_SORTER1] = "PRI";
		if (isset($USERS_SORTER2)) {
			$_SESSION[$thiss->DETECT_TABLE_COLUMN]['USERS_SORTER_SQL'] = "ORDER BY ".RELATIVEDB_SRC_COLUMN($USERS_SORTER1).",".RELATIVEDB_SRC_COLUMN($USERS_SORTER2);
			$_SESSION['USERS_SORTER_SQL'] = "ORDER BY $USERS_SORTER1, $USERS_SORTER2";//TODO REMOVE
		}
	}
	else if ($USERS_SORTER2) {
		$_SESSION[$thiss->DETECT_TABLE_COLUMN]['USERS_SORTER_SQL'] = $_SESSION[$thiss->DETECT_TABLE_COLUMN]['USERS_SORTER_SQL'].",".RELATIVEDB_SRC_COLUMN($USERS_SORTER2);
		$_SESSION[$thiss->DETECT_TABLE_COLUMN]['SORTED'][$USERS_SORTER2] = "SEC";
	}
	if ($_SESSION['DEBUG']) echo "f.USERS_SORTER done for $thiss->DETECT_TABLE_COLUMN *";
}




SEF("DETECT_TABLE_COLUMN");







function SESSION_DEBUG($ARG1,$ARG1_VAL) {
echo "test";
$_SESSION['DEBUG'] = "$ARG1_VAL";
}


function USERS_COLUMN_MENU() {
global $thiss,$USERS_COLUMN;

DETECT_TABLE_COLUMN();

if($_SESSION['DEBUG']) echo "*f.USERS_COLUMN_MENU $thiss->DETECT_TABLE_COLUMN*";
if(!empty($_REQUEST['FUNCTION_INIT']) && $_REQUEST['FUNCTION_INIT'] == 'USERS_COLUMN_MENU') $_SESSION['CURRENT_MENU'] = 'USERS_COLUMN_MENU';
CREATE_MENUFUNC_NOTD_INIT($_SESSION['LAST_MENU'], 'POWROT<img src=icon/back.gif border=0 alt=POWROT>');
echo "\n<table width='100%' border='1' cellspacing='0' cellpadding='0'>";
    foreach ($_SESSION[$thiss->DETECT_TABLE_COLUMN]['ID'] as $value) {
     if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT'][$_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC'][$value]],'R')) {
     echo "<tr><td><font size='+0'>" ; 
   if($_SESSION[$thiss->DETECT_TABLE_COLUMN]['HIDE'][$value] == 'HIDE') echo "<font color='#bbbbbb'>";
     echo "<b>";
       if($_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC_TO_LANG'][$_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC']["$value"]]) { echo $_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC_TO_LANG'][$_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC']["$value"]] . "<br>";
       echo "<font size=-2>".$_SESSION[$thiss->DETECT_TABLE_COLUMN]["DESC"]["$value"]."</font>";
       } else echo $_SESSION[$thiss->DETECT_TABLE_COLUMN]["DESC"]["$value"];
     echo "</font></b></td><td>"; 
if($_SESSION[$thiss->DETECT_TABLE_COLUMN]['SORTED'][$_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC'][$value]] == 'PRI') $border=1; else $border=0; // echo "<font color='red'><b>&lt;&lt;&lt;</b></font>";
    CREATE_MENU_NOTD_INIT_2('USERS_SORTER','USERS_SORTER','USERS_SORTER1',$_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC'][$value],'<img src=icon/sortred.gif width=8 border='.$border.' alt=sortuj>') ; 
if($_SESSION[$thiss->DETECT_TABLE_COLUMN]['SORTED'][$_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC'][$value]] == 'SEC') $border=1; else $border=0; // echo "<font color='green'><img src=icon/sort.gif width=12 border=0 alt=sortuj></font>";
    CREATE_MENU_NOTD_INIT_2('USERS_SORTER','USERS_SORTER','USERS_SORTER2',$_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC'][$value],'<img src=icon/sort.gif width=8 border='.$border.' alt=sortuj>') ; 
   if(!$_SESSION[$thiss->DETECT_TABLE_COLUMN]['HIDE'][$value] == 'HIDE') CREATE_MENU_NOTD_INIT_3('USERS_COLUMN',$value,'HIDE','<img src=icon/shutdown.gif  border=0 alt=sortuj>') ; else CREATE_MENU_NOTD_INIT_3('USERS_COLUMN',$value,'','POKAZ') ;

     echo "</font></td></tr>"; 
     }  
    }

  echo "</table>";
//CREATE_MENUFUNC_INIT(MENU,MENU);
CREATE_MENUFUNC_NOTD_INIT($_SESSION['LAST_MENU'],'POWROT<img src=icon/back.gif border=0 alt=POWROT>');
}


SEF("GETZAPSQL");

SEF('USERS');





SEF('USERS2_OFFERS');

SEF('A_PROBLEM');
SEF("M_DIST_DESC_HTML");
SEF('ORDERER');



SEF('S_HW');



function DATA_DOK($COMMAND,$DATA_DOK) {
global $result,$thiss,$error;
 if($COMMAND==POST_VERIFY) { 
	$DATA_DOK_arr=split("-",$_POST['DATA_DOK']);
	if(!$DATA_DOK_arr[2]) $error.="ZBYT KROTKI WPIS DATY (YYYY-MM-DD), uzywaj myslnika do oddzielania roku-miesiac-dnia."; 
	if($DATA_DOK_arr[3]) $error.="ZLY FORMAT DATY  (YYYY-MM-DD),  uzywaj myslnika do oddzielania roku-miesiac-dnia."; 
//TODO LEPSZA WERYFIKACJA DATY	if($DATA_DOK_arr[3]) $error.="ZLY FORMAT DATY  (YYYY-MM-DD),  uzywaj myslnika do oddzielania roku-miesiac-dnia."; 


  } else {
  if($_SESSION[CURRENT_MENU]==$thiss->DETECT_EDIT_FUNCTION) {

      if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT']['DATA_DOK'],"RW")) {
        GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDIT_TEMPLATE]['DATA_DOK'],$_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['DATA_DOK'],'DATA_DOK');
	 echo " ( $DATA_DOK $thiss->DETECT_TABLE_COLUMN )" . $_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC']['DATA_DOK'] ;
       }

  
  } else  if($_SESSION[CURRENT_MENU]=="NEW_RECORD") {

      if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT']['DATA_DOK'],"RW")) {
        GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDIT_TEMPLATE]['DATA_DOK'],$_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['DATA_DOK'],'DATA_DOK');
	 echo " ( $DATA_DOK $thiss->DETECT_TABLE_COLUMN )" . $_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC']['DATA_DOK'] ;
       }
  } else    echo $DATA_DOK."";
 }

}


function ILOSC($COMMAND,$ILOSC) {
global $result,$thiss,$error;
 if($COMMAND==POST_VERIFY) { 
	$ILOSC_arr=split(",",$_POST['ILOSC']);
	//if(!$ILOSC_arr[2]) $error.="ZBYT KROTKI WPIS DATY (YYYY-MM-DD), uzywaj myslnika do oddzielania roku-miesiac-dnia."; 
         if(strstr($_POST['ILOSC'],'pisz')) $error.="Wpisz ILOSC WYSTEPOWANIA PRODUKTU";
         if(strlen($_POST['ILOSC'])==0) $error.="Wpisz ILOSC WYSTEPOWANIA PRODUKTU";
         if($_POST['ILOSC']<=0)$error.="Wpisz prawidlowa ILOSC WYSTEPOWANIA PRODUKTU";
	if($ILOSC_arr[3]) $error.="ZLY FORMAT ILOSCI ,  uzywaj przecinka do oddzielania wartosci ."; 
//TODO LEPSZA WERYFIKACJA DATY	if($ILOSC_arr[3]) $error.="ZLY FORMAT DATY  (YYYY-MM-DD),  uzywaj myslnika do oddzielania roku-miesiac-dnia."; 
//echo "weryfikacja ILOSCI $COMMAND, $ILOSC ";

  } else {
  if($_SESSION[CURRENT_MENU]==$thiss->DETECT_EDIT_FUNCTION) {

      if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT']['ILOSC'],"RW")) {
        GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDIT_TEMPLATE]['ILOSC'],$_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['ILOSC'],'ILOSC');
	 echo " ( $ILOSC $thiss->DETECT_TABLE_COLUMN )" . $_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC']['ILOSC'] ;
       }

  
  } else  if($_SESSION[CURRENT_MENU]=="NEW_RECORD") {

      if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT']['ILOSC'],"RW")) {
        GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDIT_TEMPLATE]['ILOSC'],$_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['ILOSC'],'ILOSC');
	 echo " ( $ILOSC $thiss->DETECT_TABLE_COLUMN )" . $_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC']['ILOSC'] ;
       }
  } else    echo $ILOSC."";
 }

}



function NR_POZ($COMMAND,$NR_POZ) {
global $result,$thiss,$error,$PHP_SELF;
 if($COMMAND==POST_VERIFY) { 

     //WERYFIKACJA NIEPOTRZEBNA

  } else {
  if($_SESSION[CURRENT_MENU]==$thiss->DETECT_EDIT_FUNCTION) {

      if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT']['NR_POZ'],"RW")) {
        GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDIT_TEMPLATE]['NR_POZ'],$_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['NR_POZ'],'NR_POZ');
	 echo " ( $NR_POZ  <a href=\"$PHP_SELF?FUNCTION_INIT=COPY_RECORD&ARG1=NR_POZ&ARG1_VAL=".$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]."\">  SKOPIUJ_POZYCJE </a> )" . $_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC']['NR_POZ'] ;
       }

  
  } else  if($_SESSION[CURRENT_MENU]=="NEW_RECORD") {

      if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT']['NR_POZ'],"RW")) {
        GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDIT_TEMPLATE]['NR_POZ'],$_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['NR_POZ'],'NR_POZ');
	 echo " ( $NR_POZ $thiss->DETECT_TABLE_COLUMN )" . $_SESSION[$thiss->DETECT_TABLE_COLUMN]['DESC']['NR_POZ'] ;
       }
  } else    echo $NR_POZ." ";
 }

}



SEF('COPY_RECORD');

SEF('L_APPOITMENT_PERIOD');
SEF('L_APPOITMENT_DATE');
SEF('L_APPOITMENT_USER');
SEF('L_APPOITMENT_RESULT');
SEF('T_APPOITMENT_USER_SELECT');

SEF('T_WHO_CONNECTED');
SEF('T_WHO_CONNECTED_USER_SELECT');

SEF("T_NETWORK_SERVER_SELECT");
SEF("T_TELBOX_NEIGHBOUR_IN_SELECT");
SEF("T_TELBOX_BUILDING_IN");


SEF('ID_SPRZEDAWCA');

SEF('ID_PROJECT');


SEF('T_WORKPOINTS_USER_SELECT');


function T_WORKPOINTS_DATE_SELECT() {
global $thiss;
	CREATE_MENU_NOTD_INIT_3('TEMPEDIT_EVAL', 'T_WORKPOINTS_DATE', date('Y')."-".date('m')."-".(date('d')-1), 'WCZORAJ');
	echo " | ";
	CREATE_MENU_NOTD_INIT_3('TEMPEDIT_EVAL', 'T_WORKPOINTS_DATE', date('Y')."-".date('m')."-".date('d')."-".date('H').":".date('i'), 'TERAZ');
	echo " | ";
	CREATE_MENU_NOTD_INIT_3('TEMPEDIT_EVAL', 'T_WORKPOINTS_DATE', $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['L_APPOITMENT_DATE'], 'SPOTKANIE');
}


function T_WORKPOINTS_VALUE_TYPES() {
$T_WORKPOINTS_VALUE_TYPES[1]['TYPE']='BEZPLATNIE';
$T_WORKPOINTS_VALUE_TYPES[2]['TYPE']='USTERKA';
$T_WORKPOINTS_VALUE_TYPES[3]['TYPE']='USTERKA_PLATNA';
$T_WORKPOINTS_VALUE_TYPES[4]['TYPE']='PRZELACZENIE';
$T_WORKPOINTS_VALUE_TYPES[1]['VALUE']="0";
$T_WORKPOINTS_VALUE_TYPES[2]['VALUE']="16";
$T_WORKPOINTS_VALUE_TYPES[3]['VALUE']="19";
$T_WORKPOINTS_VALUE_TYPES[4]['VALUE']="20";
foreach ($T_WORKPOINTS_VALUE_TYPES as $value) {
	CREATE_MENU_NOTD_INIT_3('TEMPEDIT_EVAL', 'T_WORKPOINTS_VALUE', $value['VALUE'], $value['TYPE']);
	echo " | ";
}
}


function T_WORKPOINTS_TYPE_TYPES() {
$T_WORKPOINTS_TYPE_TYPES[1]['TYPE']='Technik_w_dyzurze';
$T_WORKPOINTS_TYPE_TYPES[2]['TYPE']='Administrator_w_godzinach';
$T_WORKPOINTS_TYPE_TYPES[3]['TYPE']='Technik_w_akordzie';
$T_WORKPOINTS_TYPE_TYPES[4]['TYPE']='Naprawa_gwarancyjna';
$T_WORKPOINTS_TYPE_TYPES[1]['VALUE']="TECH_AT_DUTY";
$T_WORKPOINTS_TYPE_TYPES[2]['VALUE']="ADMIN_AT_WORK";
$T_WORKPOINTS_TYPE_TYPES[3]['VALUE']="TECH_AT_CONTRACT";
$T_WORKPOINTS_TYPE_TYPES[4]['VALUE']="GUARANTY_SERVICE";
echo "<select name=T_WORKPOINTS_TYPE><option value=''> </option>
 ";

foreach ($T_WORKPOINTS_TYPE_TYPES as $value) {
	echo "<option value='" . $value['VALUE'] . "'" ;
if($_SESSION['USERS2_COLUMN']['EDITRECORD']['T_WORKPOINTS_TYPE'] == $value['VALUE']) echo "selected";
	echo ">" . $value['TYPE'] . "</option>" ;
	echo "asd";
	 }
	echo "</select>";
//	CREATE_MENU_NOTD_INIT_3(TEMPEDIT_EVAL,T_WORKPOINTS_TYPE,$value[VALUE],$value[TYPE]);
//	echo " | ";
}


function P_ACCOUNT_TYPES() {
$P_ACCOUNT_TYPES[1]['TYPE']='BEZPLATNIE';
$P_ACCOUNT_TYPES[2]['TYPE']='USTERKA_PLATNA_do_1g';
$P_ACCOUNT_TYPES[3]['TYPE']='USTERKA_PLATNA_do_2g';
$P_ACCOUNT_TYPES[1]['VALUE']="";
$P_ACCOUNT_TYPES[2]['VALUE']="30";
$P_ACCOUNT_TYPES[3]['VALUE']="60";
foreach ($P_ACCOUNT_TYPES as $value) {
	CREATE_MENU_NOTD_INIT_3('TEMPEDIT_EVAL', 'P_ACCOUNT', $value['VALUE'], $value['TYPE']);
	echo " | ";
}
}

 //EOF function N_AVG_TRAFFIC($ID,$N_AVG_TRAFFIC)


function T_NETWORK_SERVER($COMMAND) {
global $thiss ;
 if ($COMMAND == 'POST_VERIFY') {
  echo "T_NETWORK_SERVER not currentlny VERYFING...";
 } else {
  if (($_SESSION['CURRENT_MENU'] == $thiss->DETECT_EDIT_FUNCTION) || ($_SESSION['CURRENT_MENU'] == 'NEW_RECORD')) {
   T_NETWORK_SERVER_SELECT();
   echo "(".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['T_NETWORK_SERVER'].")";
  } else echo $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['T_NETWORK_SERVER'];
 }
}


SEF('BUILDING_SHOW_INVENTORY');

SEF('TELBOX_SHOW_MINI');


function T_TELBOX_ADDRESS($ID) {
 global $thiss;
 echo $_SESSION['USERS2_COLUMN']['EDITRECORD']['T_TELBOX_ADDRESS']." ";
GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['T_TELBOX_ADDRESS'], $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['T_TELBOX_ADDRESS'], 'T_TELBOX_ADDRESS');
 if(strlen($_SESSION['USERS2_COLUMN']['EDITRECORD']['T_TELBOX_ADDRESS']) > 1) {
  echo "&nbsp;<a href=\"JavaScript:
  mywindow = window.open('', 'TELBOX', 'width=400,height=400,top=100,left=100,resizable=yes,scrollbars=yes');
  mywindow.location.href = '$PHP_SELF?FUNCTION_INIT=TELBOX_SHOW_MINI&ARG1=T_TELBOX_NAME&ARG1_VAL=".$_SESSION['USERS2_COLUMN']['EDITRECORD']['T_TELBOX_ADDRESS']."';
  mywindow.focus();\"><img src=icon/search.gif border=0></a>";
 }
}


function T_TELBOX_NAME($ID) {
	global $thiss;
	if ($COMMAND == 'POST_VERIFY') {
		return;
	}
  if ($_SESSION['CURRENT_MENU'] == $thiss->DETECT_EDIT_FUNCTION) {
		echo $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['T_TELBOX_NAME'];
		echo "&nbsp;<a href=\"JavaScript:
mywindow = window.open('', 'TELBOX', 'width=400,height=400,top=100,left=100,resizable=yes,scrollbars=yes');
mywindow.location.href = '$PHP_SELF?FUNCTION_INIT=TELBOX_SHOW_MINI&ARG1=T_TELBOX_NAME&ARG1_VAL=".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['NEW_RECORD']['T_TELBOX_NAME']."';
mywindow.focus();\">Sprawdz ".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['NEW_RECORD']['T_TELBOX_NAME']."</a>";
	}
	else if ($_SESSION['CURRENT_MENU'] == 'NEW_RECORD') {
		GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['NEW_RECORD']['T_TELBOX_NAME'], $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['T_TELBOX_NAME'], 'T_TELBOX_NAME');
	}
}


SEF("P_SERVICE");


function P_SERVICE_QUOTA_PROFILE($ID) {
//echo $_SESSION[USERS_COLUMN][EDITRECORD][P_SERVICE_QUOTA_PROFILE];
echo "OK($ID)";
}


function A_STATUS($COMMAND) {
 global $error,$thiss,$ARG1,$ARG1_VAL,$result;
 if ($COMMAND == 'POST_VERIFY') {
  $_POST['TAB_UPDATE_STAT']="1";
 } else {
  if ($_SESSION['CURRENT_MENU'] == $thiss->DETECT_EDIT_FUNCTION) {
if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT']['A_STATUS'],'W'))  GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_STATUS'], $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['A_STATUS'], 'A_STATUS');
  else echo $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_STATUS']; 
// GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_STATUS'], $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['A_STATUS'], 'A_STATUS');
 if($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_STATUS'] == 'WAITING') echo "&nbsp;<a target=blank href=$PHP_SELF?FUNCTION_INIT=ORDERER&ARG1_VAL=ZLECENIE_MONTAZU><img src=icon/print.gif border=0 alt=DRUKUJ_ZLECENIE_MONTAZU></a>";
// echo "** $thiss->DETECT_TABLE_COLUMN***";
  } 
 }
}


function A_STATUS_CURRENT($COMMAND) {
 global $error,$thiss,$ARG1,$ARG1_VAL,$result,$A_STATUS_L2_SQL;
 if ($COMMAND == 'POST_VERIFY') {
  $_POST['TAB_UPDATE_STAT']="1" ;
 } else {
  if ($_SESSION['CURRENT_MENU'] == $thiss->DETECT_EDIT_FUNCTION) {
  	if(substr($thiss->DETECT_TABLE_NAME,0,4)=='SES_' && substr($thiss->DETECT_TABLE_NAME,-2)=='_A') 
	  		{
	  		
	  		$zap_sql="SELECT ".$A_STATUS_L2_SQL." as A_STATUS from ".$thiss->DETECT_TABLE_NAME." as U 
	  		left join SERVICES as SV on SV.ID=U.ID_SERVICES
	  		where  U.ID='".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDIT_TEMPLATE']['ID']."' ";//szukamy czy jest oznaczony poczatek liczenia abonamentu !!!
	  	    ZAP_SQL($zap_sql);
	  	           while ($h=mysql_fetch_object($result)) {
	  	              echo $h->A_STATUS ;
	  	              $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_STATUS_CURRENT']=$h->A_STATUS;
	  	           }
	  	
	  	  } else {
	  	
	  	
	  				if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT']['A_STATUS_CURRENT'],'W'))  GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_STATUS_CURRENT'], $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['A_STATUS_CURRENT'], 'A_STATUS_CURRENT');
	  				else echo $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_STATUS_CURRENT']; 
	  				// if($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][A_STATUS_CURRENT]==WAITING) echo "&nbsp;<a target=blank href=$PHP_SELF?FUNCTION_INIT=ORDERER&ARG1_VAL=ZLECENIE_MONTAZU><img src=icon/print.gif border=0 alt=DRUKUJ_ZLECENIE_MONTAZU></a>";
	  				// echo "** $thiss->DETECT_TABLE_COLUMN***";
	  	 } 
 	}
  }
}


function P_DEALNUMBER($ID) {
global $thiss,$ARG1,$ARG1_VAL,$result;
 if ($COMMAND == 'POST_VERIFY') {
 } else {
  if ($_SESSION['CURRENT_MENU'] == $thiss->DETECT_EDIT_FUNCTION) {
   echo $_SESSION['USERS2_COLUMN']['EDITRECORD']['P_DEALNUMBER']." ";
   GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['P_DEALNUMBER'], $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['P_DEALNUMBER'], 'P_DEALNUMBER'); 
   echo "&nbsp; <a href='$PHP_SELF?MENU_INIT=P_DEALNUMBER' target='blank'><img src=icon/print.gif border=0 alt=DRUKUJ></a> ";
  } else if ($_SESSION['CURRENT_MENU'] == 'P_DEALNUMBER') {
   require("icon/superedit-deal.frm");
  }
 }
} //EOF function P_DEALNUMBER


SEF("B_INVENTORY_DATE");


SEF("UPDATEDB");
SEF("TABLE_UPDATEDB");
SEF("TABLE_INSERTDB");

SEF("EDIT_TABLE_RECORD");

SEF("NEW_RECORD");

SEF('FILTER_SEARCH');


function TOOLBAR_DETECT() {
global $thiss;
if($_SESSION['DEBUG']) echo "*f.TOOLBAR_DETECT*\n";
 if($thiss->DETECT_TABLE_COLUMN == 'USERSHIST_COLUMN') {
  CREATE_MENUFUNC_INIT('USERS_COLUMN_MENU','<img src=icon/excel.gif alt=WYBIERZ_KOLUMNY border=0 width=18>');
 } else if ($thiss->DETECT_TABLE_COLUMN == 'USERS2_COLUMN') {
 } else if (($thiss->DETECT_TABLE_COLUMN == 'TELBOXHIST_COLUMN') || ($thiss->DETECT_TABLE_COLUMN == 'BUILDINGS_HIST_COLUMN') || ($thiss->DETECT_TABLE_COLUMN == 'DEVICESHIST_COLUMN')) {
  CREATE_MENUFUNC_INIT_2($thiss->DETECT_EDIT_FUNCTION, 'EDIT', $_SESSION[$thiss->DETECT_TABLE_COLUMN]['WIEVID'], '<img src=icon/edit.gif alt=EDYCJA border=0 width=20>') ;
  echo "&nbsp;";
  CREATE_MENUFUNC_INIT('USERS_COLUMN_MENU', '<img src=icon/excel.gif alt=WYBIERZ_KOLUMNY border=0 width=18>');
 } else {
  CREATE_MENUFUNC_INIT_2($thiss->DETECT_EDIT_FUNCTION, 'EDIT', $_SESSION[$thiss->DETECT_TABLE_COLUMN]['WIEVID'], '<img src=icon/edit.gif alt=EDYCJA border=0 width=20>') ;
CREATE_MENUFUNC_INIT('USERS_COLUMN_MENU', '<img src=icon/excel.gif alt=WYBIERZ_KOLUMNY border=0 width=18>');
 }
}


SEF('WIEVTABLE_HIST');

SEF('USERS_COLUMN_COLOR');
SEF('USERS_COLUMN_COLOR_RETURN');


SEF('CRM_LISTA_ZASOBOW_ID_SELECT');


function CREATE_MENU($HREF,$VALUE,$DESC) {
	echo '<TD><a href="'.$_SERVER['PHP_SELF']."?$HREF=$VALUE".'">'.$DESC.'</a></TD>';
}

function CREATE_MENU_INIT($HREF,$VALUE,$DESC) {
	echo '<TD><a href="'.$_SERVER['PHP_SELF']."?FUNCTION_INIT=$HREF&$HREF=$VALUE".'">'.$DESC.'</a></TD>';
}

function CREATE_MENUFUNC_INIT($HREF,$DESC) {
	echo '<TD><a href="'.$_SERVER['PHP_SELF']."?MENU_INIT=$HREF".'">'.$DESC.'</a></TD>';
}

function CREATE_MENUFUNC_INIT_2($HREF,$ARG1,$ARG1_VAL,$DESC) {
	echo '<a href="'.$_SERVER['PHP_SELF']."?MENU_INIT=$HREF&ARG1=$ARG1&ARG1_VAL=$ARG1_VAL".'">'.$DESC.'</a>';
}

function CREATE_MENUFUNC_NOTD_INIT($HREF,$DESC) {
	echo '<a href="'.$_SERVER['PHP_SELF']."?MENU_INIT=$HREF".'">'.$DESC.'</a>';
}

function CREATE_MENU_NOTD($HREF,$VALUE,$DESC) {
	echo '<a href="'.$_SERVER['PHP_SELF']."?$HREF=$VALUE".'">'.$DESC.'</a>&nbsp;';
}

function CREATE_MENU_NOTD_INIT($HREF,$VALUE,$DESC) {
	echo '<a href="'.$_SERVER['PHP_SELF']."?FUNCTION_INIT=$HREF&$HREF=$VALUE".'">'.$DESC.'</a>&nbsp;';
}
function CREATE_MENU_NOTD_INIT_2($HREF,$VALUE,$HREF2,$VALUE2,$DESC,$ALT='') {
	echo '<a href="'.$_SERVER['PHP_SELF']."?FUNCTION_INIT=$HREF&$HREF=$VALUE&$HREF2=$VALUE2".'" title="'.$ALT.'">'.$DESC.'</a>&nbsp;';
}
function CREATE_MENU_NOTD_INIT_3($HREF,$ARG1,$ARG1_VAL,$DESC) {
	echo '<a href="'.$_SERVER['PHP_SELF']."?FUNCTION_INIT=$HREF&ARG1=$ARG1&ARG1_VAL=$ARG1_VAL".'">'.$DESC.'</a>&nbsp;';
}


function DOL() {
echo "</BODY></HTML>";
return;
}

function USERS_COLUMN($ARG1, $ARG1_VAL) {
	global $thiss;
	if (isset($ARG1) && isset($ARG1_VAL)) {
		$_SESSION[$thiss->DETECT_TABLE_COLUMN]['HIDE'][$ARG1]=$ARG1_VAL;
		$_SESSION['USER_PROFILE'][$thiss->DETECT_TABLE_COLUMN][$ARG1]="$ARG1_VAL";
		// setcookie ("COOKIE_USERS_COLUMN[HIDE][$ARG1]", "$ARG1_VAL", time()+60*60*24*365, "/index.php", "abo.nsm.pl",0 );
		SEF("SAVE_PROFILE");
		SAVE_PROFILE();
	} else {
		echo "FUNCJA USERS_COLUMN - brak ARG1_VAL";
	}
}

SEF('USERS2_OFFERS_GROUPS');// 2012-09-11

SEF('USERS2_MARKETING_AKCJE');

SEF('T_WORKPOINTS_MONTH');

SEF('USERS2_OFFERS_COSTS_SALES_PLAN');
SEF('USERS2_PRODUKT');
