<?php


function T_WHEN_CONNECTED($ID) {
 global $error,$thiss,$result;

 if($COMMAND=='POST_VERIFY') { 
   echo "Weryfikacja niedostepna";
  } else {
  if($_SESSION['CURRENT_MENU']==$thiss->DETECT_EDIT_FUNCTION) {
    		//Wykrycie tabeli nazwy tabeli  SES_X_C
	if(substr($thiss->DETECT_TABLE_NAME,0,4)=='SES_' && substr($thiss->DETECT_TABLE_NAME,-2)=='_A') {
	
	//	echo "<h2>Detect table name=:".$thiss->DETECT_TABLE_NAME."</h2>";

     $SES_B_COLUMN=substr($thiss->DETECT_TABLE_NAME,0,(strlen($thiss->DETECT_TABLE_NAME)-1))."B" ; //tabela do zapisow poczatek billingu
			$zap_sql="SELECT * from ".$SES_B_COLUMN." where ID_SERVICES='".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDIT_TEMPLATE']['ID_SERVICES']."' and TYPE='4' ";//szukamy czy jest oznaczony poczatek liczenia abonamentu !!!
		//	echo $zap_sql;
      ZAP_SQL($zap_sql); 
       echo "<table border=1 cellspacing=0 cellpadding=1>";
       while ($h=mysql_fetch_object($result)) {
          echo "<tr>";
	  echo "<td ".USERS_COLUMN_COLOR_RETURN(A_STATUS,$h->A_STATUS,bgcolor)."><a href=$PHP_SELF?MENU_INIT=EXTRA_SERVICES_EDIT&ARG1=EDIT&ARG1_VAL=".$h->ID." alt=EDYCJA_PODRZEDNEJ_USLUGI>".$h->E_SERVICE." ".$h->A_STATUS_INFO."</a></td>" ; 
          echo "<td>Zanotowano w systemie L2 datę podłączenia ( TYP 4 ) :ID".$h->ID." , DATA ROZPOCZECIA BILLINGU: ".substr($h->VALUE1,0,10)."</td>";       
				$DETECTED_T_WHEN_CONNECTED_L2=substr($h->VALUE1,0,10);
				if($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['T_WHEN_CONNECTED']<>$DETECTED_T_WHEN_CONNECTED_L2) echo "<font color=red><br> ERROR w datach L2!=T_WHEN_CONNECTED</font>";
 	echo "</tr>";

       }
          echo "</table>";
// GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['T_WHEN_CONNECTED'],$_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['T_WHEN_CONNECTED'],'T_WHEN_CONNECTED'); 
if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT']['T_WHEN_CONNECTED'],"W")&&(!isset($DETECTED_T_WHEN_CONNECTED_L2)))  GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['T_WHEN_CONNECTED'],$_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['T_WHEN_CONNECTED'],'T_WHEN_CONNECTED'); else echo $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['T_WHEN_CONNECTED'] ;

//TODO
  //echo "<a href=$PHP_SELF?MENU_INIT=NEW_EXTRA_SERVICES&ARG1=NEWRECORDPARENT&ARG1_VAL".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDIT_TEMPLATE']['ID'].">++++ tu będzie dodanie daty podłączenia!!</a>";
    
  }  else if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT']['T_WHEN_CONNECTED'],"W")) GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['T_WHEN_CONNECTED'],$_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['T_WHEN_CONNECTED'],'T_WHEN_CONNECTED'); else echo $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['T_WHEN_CONNECTED'] ;
 } else if(strstr($_SESSION[$thiss->DETECT_TABLE_COLUMN]['PERMEDIT']['T_WHEN_CONNECTED'],"W")) GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['T_WHEN_CONNECTED'],$_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['T_WHEN_CONNECTED'],'T_WHEN_CONNECTED'); else echo $_SESSION[$thiss->DETECT_TABLE_COLUMN]['T_WHEN_CONNECTED']['T_WHEN_CONNECTED'] ;


}
}
