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

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

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

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

	
  	if(!empty($_REQUEST['JAVA_VALUE'])) {
		

		if($_REQUEST['JAVA_FIELD']=='P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS') {	
		   //  $where=" ID_BILLING_USERS='".$_REQUEST['JAVA_VALUE']."'";	
			 $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS']=$_REQUEST['JAVA_VALUE'];
		} else if($_REQUEST['JAVA_FIELD']==$field_name.'__JAVA') {
		    $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name.'__JAVA']=$_REQUEST['JAVA_VALUE'];
		}

		
	}
	
		$where=" where  ID like '%".addslashes($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name.'__JAVA'])."%'  
		                and ID_BILLING_USERS like '%".addslashes($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS'])."%'  
		";

	$sql = "select `ID` as `key`, concat_ws(' ','ID rekordu Deals:',ID,'; Numer P_DEALNUMBER/PREFIX:',P_DEALNUMBER,P_DEALPREFIX,';  UserID:',`ID_BILLING_USERS`, '; z dnia ',`P_DEALDATE`) as description  from `DEALS_TABLE` ".$where." order by `ID` 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-1//TRANSLIT", $r->description));
		$i++;
	}
	if(empty($rows)) {
		$rows[0]->key='';
		$rows[0]->description='';
		$rows[0]->description2='';
		$rows[0]->description3='';
	}
//	echo $sql;

  
    	 

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


  	} else {
  
  echo "Numer Umowy: <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');>";
  echo "Numer Platnika:<input type=text name=".$field_name."__JAVA_FILTR_ID_BILLING_USERS id=\"P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS\" onkeyup=JAVA_GET_SELECT_TABLE_SELECT_FROM_FIELD('".$field_name."','".session_id()."','P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS','".$field_name."__JAVA_P');>";
//  echo "<input type=text name=\"P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS\" id=\"P_DEALNUMBER_OLD__JAVA_FILTR_ID_BILLING_USERS\" value=\"asdf\">";

  echo "<select id=".$field_name."__JAVA_P name=".$field_name.">";
  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>";

	
	}
}
