<?php



include("superedit-SEF.php");


//do konfiga pietro nizej
$L_APPOINTMENT_VERIFY_USER_SQL_MODE=" and L_APPOITMENT_TYPE not in ('TO_ARRANGE','WAIT') " ;
$L_APPOINTMENT_VERIFY_TELBOX_SQL_MODE=" and L_APPOITMENT_TYPE not in ('TO_ARRANGE','WAIT') " ;


//print_r($_SERVER);




$FOLDERS['IN7_DZIENNIK_KORESP_COLUMN']="/home/samba/BIALL-NET/PISMA";
$FOLDERS['IN7_DZIENNIK_KORESP_COLUMN_PATH']="//se.dev.webone.pl/BIALL-NET/PISMA";
$FOLDERS['IN7_DZIENNIK_KORESP_COLUMN_WWW']="/ZASOB.31/BIALL-NET/PISMA";


//$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_WWW]="sowa.webone.pl/PROJEKTY";
//     $FOUND_FILES["TEN_PRODUKT"]=array_isearch_file("/".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['K_TYP_KORESP']."\$/",$files[LISTA0]);       
//2 proba > 1
//  $FOUND_FILES["TEN_PRODUKT"]=array_isearch($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][K_TYP_KORESP],$files[LISTA0]);       
//3 foreach
//	if ((!strstr($file,".".$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID].".")) )  continue;
				
$FOLDERS['IN7_DZIENNIK_KORESP_COLUMN_LOOKAT']['NEGFILE']['LOOK_REGEX']='/\.<VARNAME>\./';
$FOLDERS['IN7_DZIENNIK_KORESP_COLUMN_LOOKAT']['NEGFILE']['VARNAME']='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]';

$FOLDERS['IN7_DZIENNIK_KORESP_COLUMN_LOOKAT']['FOLDER'][1]['LOOK_REGEX']='/<VARNAME>$/';
$FOLDERS['IN7_DZIENNIK_KORESP_COLUMN_LOOKAT']['FOLDER'][1]['VARNAME']='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][K_TYP_KORESP]';


$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN']="/home/samba/PROJEKTY";
$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_PATH']="//se.dev.webone.pl/PROJEKTY";
//ex: $FOUND_FILES["TEN_PRODUKT"]=array_isearch($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID].".",$files[LISTA0]);       

$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_LOOKAT']['FOLDER'][1]['LOOK_REGEX']='/<VARNAME>./';
$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_LOOKAT']['FOLDER'][1]['VARNAME']='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]';
//$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_LOOKAT][FOLDER][2][LOOK_REGEX]='<VARNAME>.';
//$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_LOOKAT][FOLDER][2][VARNAME]='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]';


//$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_SAVE]="//sowa/PROJEKTY";
//         $FOUND_FILES["TEN_PRODUKT"]=array_isearch($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID].".",$files[LISTA0]);       


$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_WWW']="/ZASOB.31/PROJEKTY";

$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_LOOKAT']['NEGFILE']['LOOK_REGEX']='//';
$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_LOOKAT']['NEGFILE']['VARNAME']='';






		$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_DEST_FOLDER']['FOLDER'][1]['LOOK_REGEX']='<VARNAME1>.<VARNAME2>';
		$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_DEST_FOLDER']['FOLDER'][1]['VARNAME'][1]='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]';		
		$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_DEST_FOLDER']['FOLDER'][1]['VARNAME'][2]='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][M_DIST_DESC]';		
		$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_DEST_FOLDER']['M_DIST_FILES_INDEXNAME']='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][DATA_DOK]';		
		$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_DEST_FOLDER']['M_DIST_FILES_DESCRIPTION']='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][S_OTHER_INFO]';		
		$FOLDERS['IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_DEST_FOLDER']['M_DIST_FILES_TYPE_TYPES_VALUE']='PISMO';		








$FOLDERS['KSIEG_DOKUMENTY_COLUMN']="/home/samba/BIALL-NET/PISMA/IN/FAKTURY";
$FOLDERS['KSIEG_DOKUMENTY_COLUMN_PATH']="//se.dev.webone.pl/BIALL-NET/PISMA/IN/FAKTURY";
$FOLDERS['KSIEG_DOKUMENTY_COLUMN_WWW']="se.dev.webone.pl/PROJEKTY";

//Config 0 Stage
// $files[LISTA0][]=$FOLDER."/".$file;
// or other ::: if(is_dir($FOLDER."/".$file)) $files[LISTA0][]=$FOLDER."/".$file;

$FOLDERS['KSIEG_DOKUMENTY_COLUMN_LOOKAT']['DIR']='FILES';

//CONFIG 1 STAGE
$FOLDERS['KSIEG_DOKUMENTY_COLUMN_LOOKAT']['FOLDER'][1]['LOOK_REGEX']='/FAKTURY\/.$/';
$FOLDERS['KSIEG_DOKUMENTY_COLUMN_LOOKAT']['FOLDER'][1]['VARNAME']='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]';
$FOLDERS['KSIEG_DOKUMENTY_COLUMN_LOOKAT']['FOLDER'][2]['LOOK_REGEX']='/.<VARNAME>./';
$FOLDERS['KSIEG_DOKUMENTY_COLUMN_LOOKAT']['FOLDER'][2]['VARNAME']='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][DATA_DOK]';
//1.
//  $FOUND_FILES["TEN_PRODUKT"]=array_isearch(".".$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID].".",$files[LISTA0]);       
//     if(!$FOUND_FILES["TEN_PRODUKT"])
//     $FOUND_FILES["TEN_PRODUKT"]=array_isearch($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][DATA_DOK],$files[LISTA0]);       
//2 proba >1       $FOUND_FILES["TEN_PRODUKT"]=array_isearch($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][DATA_DOK],$files[LISTA0]);       
//CONFIG 3 STAGE - files negative?
$FOLDERS['KSIEG_DOKUMENTY_COLUMN_LOOKAT']['NEGFILE']['LOOK_REGEX']='.<VARNAME>.';
$FOLDERS['KSIEG_DOKUMENTY_COLUMN_LOOKAT']['NEGFILE']['VARNAME']='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]';
//3.
//if((!strstr($file,".".$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]."."))) continue;				

		$FOLDERS['KSIEG_DOKUMENTY_COLUMN_DEST_FOLDER']['M_DIST_FILES_TYPE_TYPES_VALUE']='FAKTURA';		





//DEALS_TABLE_BEGIN

		
		$FOLDERS['USERS2_DEALS_COLUMN']="/home/samba/USERS2_DEALS";
		$FOLDERS['USERS2_DEALS_COLUMN_PATH']="//se.dev.webone.pl/USERS2_DEALS";
		$FOLDERS['USERS2_DEALS_COLUMN_WWW']="/ZASOB.31/USERS2_DEALS";
		//ex: $FOUND_FILES["TEN_PRODUKT"]=array_isearch($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID].".",$files[LISTA0]);       
		
		$FOLDERS['USERS2_DEALS_COLUMN_LOOKAT']['FOLDER'][1]['LOOK_REGEX']='/\/<VARNAME>$/';
		$FOLDERS['USERS2_DEALS_COLUMN_LOOKAT']['FOLDER'][1]['VARNAME']='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]';
		//$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_LOOKAT][FOLDER][2][LOOK_REGEX]='<VARNAME>.';
		//$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_LOOKAT][FOLDER][2][VARNAME]='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]';
		
		
		//$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_SAVE]="//sowa/PROJEKTY";
		//         $FOUND_FILES["TEN_PRODUKT"]=array_isearch($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID].".",$files[LISTA0]);       
		
		
		//$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_WWW]="sowa.webone.pl/PROJEKTY";
		
		$FOLDERS['USERS2_DEALS_COLUMN_LOOKAT']['NEGFILE']['LOOK_REGEX']='//';
		$FOLDERS['USERS2_DEALS_COLUMN_LOOKAT']['NEGFILE']['VARNAME']='';
		
		
		$FOLDERS['USERS2_DEALS_COLUMN_DEST_FOLDER']['FOLDER'][1]['LOOK_REGEX']='<VARNAME1>';
		$FOLDERS['USERS2_DEALS_COLUMN_DEST_FOLDER']['FOLDER'][1]['VARNAME'][1]='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]';
//		$FOLDERS[USERS2_DEALS_COLUMN_DEST_FOLDER][FOLDER][1][VARNAME][2]='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][S_ADDRESS_STREET]';
//		$FOLDERS[USERS2_DEALS_COLUMN_DEST_FOLDER][FOLDER][1][VARNAME][3]='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][P_SERVICE]';
		
		$FOLDERS['USERS2_DEALS_COLUMN_DEST_FOLDER']['M_DIST_FILES_INDEXNAME']='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][DATA_DOK]';		

		$FOLDERS['USERS2_DEALS_COLUMN_DEST_FOLDER']['M_DIST_FILES_DESCRIPTION']='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][S_OTHER_INFO]';		
		$FOLDERS['USERS2_DEALS_COLUMN_DEST_FOLDER']['M_DIST_FILES_TYPE_TYPES_VALUE']='PISMO';		

		
		//$M_DIST_FILES_INDEXNAME=$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][K_DATA_OTRZYMANEJ_KORESP] ;

		//$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_LOOKAT][FOLDER][2][LOOK_REGEX]='<VARNAME>.';
		//$FOLDERS[IN7_MK_BAZA_DYSTRYBUCJI_COLUMN_LOOKAT][FOLDER][2][VARNAME]='$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID]';
		
		
	//	$FOLDERS[USERS2_DEALS_COLUMN_DEST_FOLDER]=."/".str_replace($BAD_FILE_SIGNS,$OK_FILE_SIGNS,$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][P_NAME]).".".$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][ID].".".str_replace($BAD_FILE_SIGNS,$OK_FILE_SIGNS,$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][P_ADDRESS_POST_CODE].$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][P_ADDRESS_CITY]) ;

		
		



//DEALS_TABLE_END







$FOLDERS['SCANS_COLUMN']="/home/samba/SKANY/skan/";
$FOLDERS['SCANS_COLUMN_PATH']="//se.dev.webone.pl/SKANY/skan";
//$FOLDERS[SCANS_COLUMN_WWW]="/home/samba/SKANY";


unset($TRG_FILE);

$TRG_FILE["ZDJECIE"][1][]=".jpg";
$TRG_FILE["ZDJECIE"][2][]=".ZDJECIE.";
$TRG_FILE["ZDJECIE"][2][]=".JPG";
$TRG_FILE["ZDJECIE_HI"][1][]=".ZDJECIE_HI.";
//$TRG_FILE["CERT_CE_WEW"][1][]=".DEKLARACJA_CE_WEW.";
//$TRG_FILE["CERT_CE_WEW"][1][]=".pdf";
//$TRG_FILE["CERT_CE"][1][]=".CERT_CE.";

//20080205 tak musi byc INSTRUKCJI PL BO w SE DATA_INSTRUKCJI_PL
//$TRG_FILE["INSTRUKCJA_PL"][1][]=".INSTRUKCJA.";
//$TRG_FILE["INSTRUKCJA_PL"][2][]=".INSTRUKCJA_PL.";
//$TRG_FILE["KARTA"][1][]=".KARTA.";
//$TRG_FILE["OVERLAY"][1][]=".OVERLAY.";
//$TRG_FILE["BOX"][1][]=".BOX.";
$TRG_FILE["FIRMWARE"][1][]=".FIRMWARE.";
$TRG_FILE["SOFT_CD"][1][]=".SOFT_CD.";
$TRG_FILE["PREZENTACJA"][1][]=".PREZENTACJA.";
//$TRG_FILE["ETYKIETA"][1][]=".ETYKIETA.";
//$TRG_FILE["CERT_CE_ZEW"][1][]=".CERT_CE_ZEW.";
$TRG_FILE["ARTYKUL"][1][]=".ARTYKUL.";
//$TRG_FILE["INSTRUKCJA_PL_DRUK"][1][]=".INSTRUKCJA_PL_DRUK.";
//$TRG_FILE["INSTRUKCJA"][1][]=".INSTRUKCJA.";
$TRG_FILE["FAKTURA"][1][]=".FAKTURA.";
//$TRG_FILE["FAKTURA_P"][1][]=".FAKTURA_P.";
$TRG_FILE["UMOWA"][1][]=".UMOWA.";
//$TRG_FILE["UMOWA_P"][1][]=".UMOWA_P.";
$TRG_FILE["PISMO"][1][]=".PISMO.";
$TRG_FILE["OFERTA"][1][]=".OFERTA.";
//$TRG_FILE["KOMPLETACJA"][1][]=".KOMPLETACJA.";
$TRG_FILE["NOTATKA"][1][]=".NOTATKA.";
$TRG_FILE["TODO"][1][]=".TODO.";
$TRG_FILE["UZGODNIENIE"][1][]=".UZGODNIENIE.";
$TRG_FILE["PROJEKT"][1][]=".PROJEKT.";
$TRG_FILE["PROJEKT_BUD"][1][]=".PROJEKT_BUD.";
$TRG_FILE["PROJEKT_GRAF"][1][]=".PROJEKT_GRAF.";
$TRG_FILE["PROTOKOL"][1][]=".PROTOKOL.";
$TRG_FILE["DOK_POWYK"][1][]=".DOK_POWYK.";
$TRG_FILE["WWW_DOKUMENTY"][1][]=".WWW_DOKUMENTY.";
$TRG_FILE["WWW_PRACA"][1][]=".WWW_PRACA.";

$_SESSION['TRG_FILE']=$TRG_FILE;


	$BAD_FILE_SIGNS=array('.',' ',',','/');
	$OK_FILE_SIGNS=array("-",'_','--','---');

SEF("BAD_FILE_SIGNS");



//$MENUS=array('USERS','SES_TV_A','EXTRA_SERVICES','TELBOXES','BUILDINGS','L_APPOITMENT_OVERWIEV','USERS2_MARKETING','USERS2_MARKETING_OVERWIEV','USERS2_OFFERS','USERS2_OFFERS_GROUPS','USERS2_OFFERS_COSTS','VOIP_CENNIK',
//'VOIP_FREE_TIME','VOIP_MAP','VOIP_PROMO','USERS2_DEALS','USERS2_WINDYKACJA','KSIEG_DOKUMENTY','IN7_MK_BAZA_DYSTRYBUCJI','IN7_DZIENNIK_KORESP');
//$MENUS_DES=array ('USERS','TV','EXTRA','TELBOXES','BUILDINGS','APP_OV','MARKETING','MARKETING OV','OFFERS','USERS2 OFFERS GROUPS','OFFERS COSTS','VOIP CENNIK',
//'VOIP FREE TIME','VOIP MAP','VOIP PROMO','DEALS','WINDY KACJA','FAKTURY','PROJEKTY','KORESP');

$MAIN_MENU = array();// COLUMN => menu title
$MAIN_MENU['SES_USERS2_A'] = 'USERS2';
$MAIN_MENU['SES_TV_A'] = 'TV';
$MAIN_MENU['EXTRA_SERVICES'] = 'EXTRA';
$MAIN_MENU['TELBOXES'] = 'TELBOXES';
$MAIN_MENU['DEVICES'] = 'DEVICES';
$MAIN_MENU['BUILDINGS'] = 'BUILDINGS';
$MAIN_MENU['L_APPOITMENT_OVERWIEV'] = 'APP_OV';
$MAIN_MENU['USERS2_MARKETING'] = 'MARKETING';
$MAIN_MENU['USERS2_MARKETING_AKCJE'] = 'AKCJE';
$MAIN_MENU['USERS2_MARKETING_OVERWIEV'] = 'MARKETING OV';
$MAIN_MENU['USERS2_MARKETING_OVERWIEV_REWIR'] = '&gt;REWIR INFO';
$MAIN_MENU['USERS2_DEALS'] = 'DEALS';
$MAIN_MENU['DEALS_TABLE'] = 'DEALS_TABLE';
$MAIN_MENU['USERS2_WINDYKACJA'] = 'WINDY KACJA';
$MAIN_MENU['USERS2_WINDYKACJA_STATUS'] = 'WINDY KACJA STATUS';
$MAIN_MENU['KSIEG_DOKUMENTY'] = 'FAKTURY';
$MAIN_MENU['IN7_MK_BAZA_DYSTRYBUCJI'] = 'PROJEKTY';
$MAIN_MENU['IN7_DZIENNIK_KORESP'] = 'KORESP';
$MAIN_MENU['USERS2_OFFERS'] = 'OFFERS';
$MAIN_MENU['USERS2_OFFERS_GROUPS'] = 'OFFERS GROUPS';
$MAIN_MENU['USERS2_OFFERS_COSTS'] = 'OFFERS COSTS';
$MAIN_MENU['USERS2_OFFERS_COSTS_GROUPS'] = 'OFFERS COSTS GROUPS';
$MAIN_MENU['VOIP_CENNIK'] = 'VOIP CENNIK';
$MAIN_MENU['VOIP_FREE_TIME'] = 'VOIP FREE TIME';
$MAIN_MENU['VOIP_MAP'] = 'VOIP MAP';
$MAIN_MENU['VOIP_PROMO'] = 'VOIP PROMO';
$MAIN_MENU['USERS2_OFFERS_COSTS_SALES_PLAN'] = 'SALES PLAN';
$MAIN_MENU['USERS2_PRODUKT'] = 'PRODUKTY';


//@2012-09-15 sprawdzamy czy gosc ma dostep!
$MENUS_CRM_AUTO = array();// [ ZASOB ID ][ FUNC NAME ] => menu title
$MENUS_CRM_AUTO[3464]['L_APPOITMENT_OVERWIEV'] = '[3464] APP_OV';
$MENUS_CRM_AUTO[3209]['USERS2_MARKETING_AKCJE'] = '[3209] AKCJE';
$MENUS_CRM_AUTO[3463]['USERS2_MARKETING_OVERWIEV'] = '[3463] MARKETING OV';
$MENUS_CRM_AUTO[2880]['USERS2_MARKETING_OVERWIEV_REWIR'] = '[2880] REWIR INFO';
$MENUS_CRM_AUTO[3462]['USERS2_OFFERS'] = '[3462] OFFERS';
$MENUS_CRM_AUTO[3461]['USERS2_OFFERS_GROUPS'] = '[3461] OFFERS GROUPS';
$MENUS_CRM_AUTO[3145]['USERS2_OFFERS_COSTS'] = '[3145] OFFERS COSTS';
$MENUS_CRM_AUTO[3460]['USERS2_OFFERS_COSTS_GROUPS'] = '[3460] OFFERS COSTS GROUPS';
$MENUS_CRM_AUTO[1949]['SES_USERS2_A'] = '[1949] USERS2';
$MENUS_CRM_AUTO[2740]['SES_TV_A'] = '[2740] TV';
$MENUS_CRM_AUTO[3603]['SES_VOIP_A'] = '[3603] VOIP';
$MENUS_CRM_AUTO[3452]['EXTRA_SERVICES'] = '[3452] EXTRA';
$MENUS_CRM_AUTO[3609]['SERVICES'] = '[3609] SERVICES';
$MENUS_CRM_AUTO[3453]['DEVICES'] = '[3453] DEVICES';
$MENUS_CRM_AUTO[3446]['TELBOXES'] = '[3446] TELBOXES';
$MENUS_CRM_AUTO[2455]['BUILDINGS'] = '[2455] BUILDINGS';
$MENUS_CRM_AUTO[2465]['USERS2_MARKETING'] = '[2465] MARKETING';
$MENUS_CRM_AUTO[261]['KSIEG_DOKUMENTY'] = '[261] FAKTURY';
$MENUS_CRM_AUTO[2518]['USERS2_WINDYKACJA'] = '[2518] WINDY KACJA';
$MENUS_CRM_AUTO[3445]['USERS2_WINDYKACJA_STATUS'] = '[2445] WINDY KACJA STATUS';
$MENUS_CRM_AUTO[2367]['IN7_MK_BAZA_DYSTRYBUCJI'] = '[2367] PROJEKTY';
$MENUS_CRM_AUTO[2168]['IN7_DZIENNIK_KORESP'] = '[2168] KORESP';
$MENUS_CRM_AUTO[3454]['VOIP_CENNIK'] = '[3454] VOIP CENNIK';
$MENUS_CRM_AUTO[3455]['VOIP_FREE_TIME'] = '[3455] VOIP FREE TIME';
$MENUS_CRM_AUTO[3456]['VOIP_MAP'] = '[3456] VOIP MAP';
$MENUS_CRM_AUTO[3457]['VOIP_PROMO'] = '[3457] VOIP PROMO';
$MENUS_CRM_AUTO[3458]['USERS2_OFFERS_COSTS_SALES_PLAN'] = '[3458] SALES PLAN';
$MENUS_CRM_AUTO[3459]['USERS2_PRODUKT'] = '[3459] PRODUKTY';
$MENUS_CRM_AUTO[1053]['USERS2_DEALS']='[1053] DEALS';
$MENUS_CRM_AUTO[3617]['BILLING_USERS_ADD']='[3617] BILLING USERS ADD';
$MENUS_CRM_AUTO[3618]['BILLING_USERS']='[3618] BILLING USERS';
$MENUS_CRM_AUTO[137]['DODAJ_WYNIK_ANKIETY_FUNC']='[137] DODAJ WYNIK ANKIETY';
$MENUS_CRM_AUTO[2468]['POKAZ_OFERTY_AKTUALNE_FUNC']='[2468] POKAZ OFERTY AKTUALNE';
$MENUS_CRM_AUTO[147]['DODAJ_REKORDY_MIESZKAN_FUNC']='[147] DODAJ REKORDY MIESZKAN';
$MENUS_CRM_AUTO[1117]['NADANIE_PROBLEMOW_FUNC']='[1117] NADANIE PROBLEMOW (marketing)';
$MENUS_CRM_AUTO[2645]['PRZYPOMNIJ_FUNC']='[2645] przypomnij';



$MENUS = array(); $MENUS_DES = array();
foreach ($MAIN_MENU as $col => $m) {
	$MENUS []= $col; $MENUS_DES []= $m;
}
$MENUS_SUB = array();
$MENUS_SUB['USERS2_MARKETING_AKCJE'] = 'USERS2_MARKETING';
$MENUS_SUB['USERS2_MARKETING_OVERWIEV'] = 'USERS2_MARKETING';
$MENUS_SUB['USERS2_MARKETING_OVERWIEV_REWIR'] = 'USERS2_MARKETING';
$MENUS_SUB['USERS2_PRODUKT'] = 'USERS2_MARKETING';
$MENUS_SUB['USERS2_OFFERS'] = 'USERS2_MARKETING';
$MENUS_SUB['USERS2_OFFERS_GROUPS'] = 'USERS2_MARKETING';
$MENUS_SUB['USERS2_OFFERS_COSTS'] = 'USERS2_MARKETING';
$MENUS_SUB['USERS2_OFFERS_COSTS_GROUPS'] = 'USERS2_MARKETING';
$MENUS_SUB['VOIP_CENNIK'] = 'USERS2_MARKETING';
$MENUS_SUB['VOIP_FREE_TIME'] = 'USERS2_MARKETING';
$MENUS_SUB['VOIP_MAP'] = 'USERS2_MARKETING';
$MENUS_SUB['VOIP_PROMO'] = 'USERS2_MARKETING';
$MENUS_SUB['USERS2_OFFERS_COSTS_SALES_PLAN'] = 'USERS2_MARKETING';
$MENUS_SUB['USERS2_WINDYKACJA_STATUS'] = 'USERS2_WINDYKACJA';


if(file_exists(dirname(__FILE__)."/config/.config_".$_SERVER['SERVER_NAME'].".php"))
       require(dirname(__FILE__)."/config/.config_".$_SERVER['SERVER_NAME'].".php");




$komputery = $localpath . "/komputery";
$komputery_www = $localpath . "/komputery-www" ;
$komputery_arr = $localpath . "/komputery-arr" ;


$special_tables_ignore_fields=array('BILLS_FVAT_2','BILLS_FVAT_POS','BILLS_FVAT_POS_HIST','L_APPOITMENT','SES_USERS2_C','SES_USERS2_C_HIST','USERS2_MARKETING_OVERWIEV_REWIR','229Wezly','229Wezly_HIST'); //tabele, ktore maja byc ignorowane przy sprawdzaniu specjalnych pol SE
$special_tables_ignore_init=array('L_APPOITMENT','BILLS_FVAT_2'); //tabele, ktore maja byc ignorowane przy inicjalizacji specjalnych pol SE



$CNF_ZASOB['14']['INTERFACE_ADDR'] = (isset($INTERFACE_ADDR))? $INTERFACE_ADDR : null;
$CNF_ZASOB['14']['SQL_USER'] = (isset($SQL_USER))? $SQL_USER : null;
$CNF_ZASOB['14']['SQL_USER_PASS'] = (isset($SQL_USER_PASS))? $SQL_USER_PASS : null;
$CNF_ZASOB['14']['SQL_DATABASE'] = (isset($SQL_DATABASE))? $SQL_DATABASE : null;



$SQL_TABLE_USERS="SES_USERS2_A" ;
$SQL_TABLE_USERS_HIST="SES_USERS2_A_HIST";

$A_STATUS_L2_SQL="if(SV.HANGUP_STATUS=SV.A_STATUS
	, coalesce(SV.A_STATUS)
	, if((unix_timestamp(NOW()) > unix_timestamp(SV.HANGUP_FROM) and (SV.HANGUP_TILL='0000-00-00' or SV.HANGUP_TILL is NULL) and (SV.HANGUP_FROM<>'0000-00-00' and SV.HANGUP_FROM is not null))
    , coalesce(SV.HANGUP_STATUS)
    , if((unix_timestamp(NOW()) < unix_timestamp(SV.HANGUP_FROM) and (SV.HANGUP_TILL='0000-00-00' or SV.HANGUP_TILL is NULL) and (SV.HANGUP_FROM<>'0000-00-00' and SV.HANGUP_FROM is not null))
			, coalesce(SV.A_STATUS)
			, if((unix_timestamp(NOW()) > unix_timestamp(SV.HANGUP_FROM) and unix_timestamp(NOW()) < unix_timestamp(SV.HANGUP_TILL) and (SV.HANGUP_TILL<>'0000-00-00' and SV.HANGUP_TILL is not NULL) and (SV.HANGUP_FROM<>'0000-00-00' and SV.HANGUP_FROM is not null))
				, coalesce(SV.HANGUP_STATUS)
				, if((unix_timestamp(NOW()) < unix_timestamp(SV.HANGUP_FROM) and unix_timestamp(NOW()) < unix_timestamp(SV.HANGUP_TILL) and (SV.HANGUP_TILL<>'0000-00-00' and SV.HANGUP_TILL is not NULL) and (SV.HANGUP_FROM<>'0000-00-00' and SV.HANGUP_FROM is not null))
					, coalesce(SV.A_STATUS)
					, if(((SV.HANGUP_TILL='0000-00-00' or SV.HANGUP_TILL is NULL) and (SV.HANGUP_FROM='0000-00-00' or SV.HANGUP_FROM is null))
						, coalesce(SV.A_STATUS)
						, if(unix_timestamp(NOW()) > unix_timestamp(SV.HANGUP_FROM) and unix_timestamp(NOW()) > unix_timestamp(SV.HANGUP_TILL) and ((SV.HANGUP_TILL<>'0000-00-00' and SV.HANGUP_TILL is not NULL) and (SV.HANGUP_FROM<>'0000-00-00' and SV.HANGUP_FROM is not null))
							, coalesce(SV.A_STATUS)
							, if(unix_timestamp(NOW()) > unix_timestamp(SV.HANGUP_FROM) and unix_timestamp(NOW()) > unix_timestamp(SV.HANGUP_TILL) and SV.HANGUP_FROM<SV.HANGUP_TILL and ((SV.HANGUP_TILL<>'0000-00-00' and SV.HANGUP_TILL is not NULL) and (SV.HANGUP_FROM<>'0000-00-00' and SV.HANGUP_FROM is not null ))
								, 'ERROR1'
								, 'ERROR2'
								)
							)
						)
					)
				)
			)
		)
	)
";//@2012-09-25 definicja pola A_STATUS na podstawie danych z L2 dla zalozen , ze tabela SERVICES jest podlaczona join SERVICES as SV "
    //        left join SERVICES as SV on SV.ID=U.ID_SERVICES
    // 		  left join BILLING_USERS_ADD as BUA on BUA.id_users=SV.ID_BILLING_USERS


$A_STATUS_L2_SQL_L1="if(LIST_status.ses_users2='NORMAL',".$A_STATUS_L2_SQL.",if ($A_STATUS_L2_SQL='NORMAL',LIST_status.ses_users2,$A_STATUS_L2_SQL))";
	//@2012-10-06 definicja pola A_STATUS na podstawie danych z L2 dla zalozen , ze tabela SERVICES jest podlaczona join SERVICES as SV 
    //        left join SERVICES as SV on SV.ID=U.ID_SERVICES
    // 		  left join BILLING_USERS_ADD as BUA on BUA.id_users=SV.ID_BILLING_USERS
    //		  left join BILLING_USERS as BU on BU.ID=SV.ID_BILLING_USERS
    //        left join LIST_status as LIST_status on LIST_status.id=BU.STATUS
