<?php
//@2013-01-10 sqix
function P_SERVICE_QUOTA_PROFILE( $cmd, $value ) {
	global $result, $thiss;

	$field_name = 'P_SERVICE_QUOTA_PROFILE'; //1::@2012-12-20 sqix: pole do ustalenia jaka nazwa komorki jest aktualnie edytowana - uzywana w odwolaniach nizej
	$select_list = array();



	if ($cmd == 'POST_VERIFY') {


	//tutaj podmieniamy numerek ID na zmienna do zapisania do bazy danych
	$sql="select P_SERVICE_QUOTA_PROFILE from LIST_USERS2_PROFILES where ID='".$_REQUEST[$field_name]."' limit 1";
  DEBUG_S(-3,'REQUEST',array($_REQUEST,$sql),__FILE__, __FUNCTION__, __LINE__);

	ZAP_SQL($sql);
	while($h=mysql_fetch_object($result)) {
		$_POST[$field_name]=$h->P_SERVICE_QUOTA_PROFILE;
	
	}

	//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;
	}

		
		//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 PROFILE_NAME 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` as `key`, concat_ws(' ',`PROFILE_NAME`) as description   from `LIST_USERS2_PROFILES` ".$where." order by `ID` 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::
    
  	//tutaj podmieniamy numerek ID na zmienna do zapisania do bazy danych
	$sql="select ID,PROFILE_NAME from LIST_USERS2_PROFILES where P_SERVICE_QUOTA_PROFILE='".$value."' limit 1";

	ZAP_SQL($sql);
	//DEBUG_S(-3,'REQUEST',array($sql),__FILE__, __FUNCTION__, __LINE__);

	while($h=mysql_fetch_object($result)) {
		$value=$h->ID;
		$current_desc=$h->PROFILE_NAME;
	
	}
  
  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','select');>";
  echo "<select id=".$field_name."__JAVA_P name=".$field_name."__JAVA_P ";
  echo " onchange=set_FORM_NAME('".$field_name."__JAVA_P','".$field_name."'); ";

  echo ">";
  

  echo "</select>";
  echo "\n<input type=text name=".$field_name." id=\"".$field_name."\" value='".$value."'>";
  if($current_desc) echo "<br>( aktualnie ID:".$value."=".$current_desc.")";
  //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>';
	
	*/
	
	}
}
?>
