<?php
//@2012-12-17 szybkie wyszukiwanie w komorkach za pomoca javy by sqix

function S_ADDRESS_STREET( $cmd, $value ) {
	global $result, $thiss;

	if ($cmd == 'POST_VERIFY') {
			  DEBUG_S(-3,'REQUEST',$_REQUEST,__FILE__, __FUNCTION__, __LINE__);
		return;
	}

	$field_name = 'S_ADDRESS_STREET';
	$select_list = array();

	
  	if(!empty($_REQUEST['JAVA_VALUE'])) {
		
		if($_REQUEST['JAVA_FIELD']==$field_name.'__JAVA') {
		    $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name.'__JAVA']=$_REQUEST['JAVA_VALUE'];
		}

		
	}
		if(!isset($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name.'__JAVA'])) $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name.'__JAVA']='';

		$where=" where  t1.S_ADDRESS_STREET like '%".addslashes($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name.'__JAVA'])."%'  
		     
		         
		"; 
	//	 if(!empty($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS'])) $where.=" and ( sua.ID_BILLING_USERS like '%".addslashes($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS'])."%'  
	//	         or sut.ID_BILLING_USERS like '%".addslashes($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS'])."%'  )
	//	        ";		             


	$sql = "select t1.`S_ADDRESS_STREET` as `key`, concat_ws(' ','ID rekordu :',t1.ID,'; REWIR:',t1.M_REWIR,'; Status Budynku:',t2.A_STATUS,'; ULICA:',t2.`P_ADDRESS_STREET`		
		) as description  from `USERS2_MARKETING` as t1 
			left join BUILDINGS as t2 on t1.`T_TELBOX_BUILDING_IN`=t2.`S_ADDRESS_STREET`";
	 //if(!empty($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS'])) 
	   // $sql.="
	//		left join SES_USERS2_A as sua on ( sua.`S_ADDRESS_STREET`=t1.`S_ADDRESS_STREET` and sua.ID_BILLING_USERS='".addslashes($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS'])."' ) 
	//		left join SES_TV_A as sut on ( sut.`S_ADDRESS_STREET`=t1.`S_ADDRESS_STREET`  and sut.ID_BILLING_USERS='".addslashes($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS'])."' )";
		$sql.=" ".$where."  limit 25 ";
	ZAP_SQL( $sql );
	$i=0;
	SEF('REMOVE_LOCALES_OGONKI');
	while ($r = mysql_fetch_object( $result )) {
		$rows[$i]->key=$r->key;
		$rows[$i]->description=addslashes(iconv("UTF-8", "ISO-8859-1//TRANSLIT", REMOVE_LOCALES_OGONKI($r->description)));
		$i++;
	}
	if(empty($rows)) {
		$rows[0]->key='';
		$rows[0]->description='';
		$rows[0]->description2='';
		$rows[0]->description3='';
	}


  
    	 

  
  	if(!empty($_REQUEST['JAVA_GET_SELECT_TABLE_SELECT'])) {
 		print json_encode($rows);


  	} else {
  
  echo "<b>Wyszukaj</b> Adres:<input type=text name=".$field_name."__JAVA id=\"".$field_name."__JAVA\" onkeyup=JAVA_GET_SELECT_TABLE_SELECT_FROM_FIELD('".$field_name."','".session_id()."','".$field_name."__JAVA','".$field_name."__JAVA_P','select');>";
  echo "<br>Niżej wybierz wyszukany adres: <br><select width=\"100%\" style=\"width: 100%\"  id=".$field_name."__JAVA_P name=".$field_name.">";
  echo "<option value=".$value.">".$value."</option>";
  
  echo "</select>";

//  echo "<select id=P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS_P name=".$field_name.">";
  //echo "</select>";
 // echo "<div id=\"P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS\"> asd ID_BILLING_W_DT</div>";

	
	}
}
