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

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

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


	//BEGIN::modul obslugi dodawania do struktury USERS2_DEALS 
	  //( 1:DEALS_TABLE->wiele:USERS2_DEALS w oparciu o opcje i parametry OFFERS oraz USERS2_OFFERS_GROUPS )
	  
	  
	//END::



		return;
	}

	$field_name = 'ID_BILLING_USERS'; //1::@2012-12-20 sqix: pole do ustalenia jaka nazwa komorki jest aktualnie edytowana - uzywana w odwolaniach nizej
	$select_list = array();
		
		//2::@2012-12-20 sqix: komponent nadpisujacy wartosc z pola wyboru JAVA
		if($_REQUEST['JAVA_FIELD']==$field_name.'__JAVA') {
					    $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name.'__JAVA']=addslashes($_REQUEST['JAVA_VALUE']);
		}
				
		//3::@2012-12-20 sqix: komponent wykonujacy odpowiednie zapytanie z uzyciem nadpisanego pola wyszukiwan $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name.'__JAVA']
		$where=" where id_users like '%".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name.'__JAVA']."%' or P_NAME_SECOND like '%".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name.'__JAVA']."%'  ";


//
    //4::@2012-12-20 sqix: komponent wykonujacy strukture zapytania odpowiednia z uzyciem komponentu 3:: jako $where ,
    // wraz z zapisaniem wartosci do zmiennej $rows i jej skompilowaniem do zmiennej gotowej do przekazania do JAVY-Client
    // koniec na //EOF::4::
	$sql = "select `id_users` as `key`, concat_ws(' ',`P_NAME`,`P_NAME_SECOND`,'; adres: ',`P_ADDRESS_CITY`,`P_ADDRESS_STREET`,`P_ADDRESS_HOUSE`) as description   from `BILLING_USERS_ADD` ".$where." order by `id_users` DESC limit 25 ";
//	$sql = "select `id_users` as `key`, concat_ws(' ',`ID`) as description   from `BILLING_USERS_ADD` ".$where." order by `id_users` DESC limit 25 ";
	ZAP_SQL( $sql );
		$i=0;
	while ($r = mysql_fetch_object( $result )) {
		$rows[$i]->key=$r->key;
//		$rows[$i]->description=addslashes(iconv("UTF-8", 'ISO-8859-2//TRANSLIT//IGNORE', $r->description));
		$rows[$i]->description=$r->description;
		$i++;
	}
	//EOF::4::
  	if(empty($rows)) {
		$rows[0]->key='';
		$rows[0]->description='';
		$rows[0]->description2='';
		$rows[0]->description3='';
	}
  
     //4::@2012-12-20 sqix: warunkujacy wywolanie tej kolumny przez JAVE-Client przekompilowujacy tablice $rows -> //EOF:4::
  	if(!empty($_REQUEST['JAVA_GET_SELECT_TABLE_SELECT'])) {
			header('Content-Type: text/html; charset=iso-8859-2');
 		//print json_encode($rows);
 		require_once dirname(__FILE__) . '/se-lib/' . 'V.php';
 		print V::json_encode_latin2($rows);


  	} else {
    //EOF:4::
    
  //5::@2012-12-20 sqix: pole wyboru generujace pole select dla danej kolumny-> //EOF:5::
  
  echo "\n<input type=text name=".$field_name."__JAVA id=\"".$field_name."__JAVA\" onkeydown=JAVA_GET_SELECT_TABLE_SELECT_FROM_FIELD('".$field_name."','".session_id()."','".$field_name."__JAVA','".$field_name."__JAVA_P');>";
  echo "<select id=".$field_name."__JAVA_P name=".$field_name."__JAVA_P ";
		if($thiss->DETECT_TABLE_COLUMN=='DEALS_TABLE_COLUMN') //jezeli w deals table, to ustawiony platnik sugeruje umowy z tego klienta
	  //5.1::@2012-12-20 sqix: mozliwosc przekazania zawartosci do innego pola formularza w JAVA -> //EOF:5.1::
			echo  "onchange=\"set_FORM_NAME('".$field_name."__JAVA_P','P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS');set_FORM_NAME('".$field_name."__JAVA_P','".$field_name."') \" ";
			//					echo  "onchange=\"set_FORM_NAME('ID_BILLING_USERS_W_DEALS_TABLE','".$field_name."__JAVA_P\"')\" ";
	 //EOF:5.1::

  echo ">";
  echo "\n<input type=text name=".$field_name." id=\"".$field_name."\" value='".$value."'>";

  echo "</select>";
  //EOF:5::

  /*
	
	echo ' >';
		echo ' <option value="">' . " " . '</option>';
		foreach ($select_list as $key => $val) {
			$sel = ($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name] == $key)? ' selected="selected"' : '';
			echo '<option value="' . $key . '"' . $sel . '>' . $val . '</option>';
		}//end foreach
	echo '</select>';
	
	*/
	
	}
}
