<?php


function A_PROBLEM($ID,$A_PROBLEM) {


global $thiss,$ARG1,$ARG1_VAL,$result,$error;

if ($_SESSION['CURRENT_MENU'] == $thiss->DETECT_EDIT_FUNCTION || $_SESSION['LAST_MENU'] == $thiss->DETECT_EDIT_FUNCTION) {
if ($_SESSION[$thiss->DETECT_TABLE_COLUMN]['WIEVID'] == $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['ID']) {
	// show action links
	if (strlen($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM']) > 0) {
		CREATE_MENUFUNC_INIT_2('A_PROBLEM', 'A_PROBLEM', 'REMOVE', 'USUN PROBLEM');
		echo "&nbsp;<a target=blank href=".$_SERVER['PHP_SELF']."?FUNCTION_INIT=ORDERER&ARG1_VAL=ZLECENIE_NAPRAWY&HEADER_NOT_INIT=YES><img src=icon/print.gif border=0 alt=DRUKUJ_ZLECENIE_MONTAZU></a>";
		echo "<font size=-1> | " ;
		if ($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM'] == 'UNVERIFIED') {
			CREATE_MENUFUNC_INIT_2('A_PROBLEM', 'A_PROBLEM', 'ADD', 'USTAW_PROBLEM');
		}
		if ($_SESSION['CURRENT_MENU'] == 'A_PROBLEM') CREATE_MENUFUNC_INIT_2('A_PROBLEM', 'ORDERER', 'POST', 'PRZESLIJ_ZLECENIE_MAIL');
		if ($_SESSION['CURRENT_MENU'] == 'A_PROBLEM') echo " | " ;
		//if($_SESSION[CURRENT_MENU]==A_PROBLEM) echo "<a href='$PHP_SELF?ARG1=ORDERER&ARG1_VAL=SHOW' target='blank'>DRUKUJ_ZLECENIE</a>"; //TODO usunac warunek dalej w funkcjach
		if ($_SESSION['CURRENT_MENU'] == 'A_PROBLEM') echo "<a href='".$_SERVER['PHP_SELF']."?FUNCTION_INIT=ORDERER&ARG1_VAL=ZLECENIE_NAPRAWY&HEADER_NOT_INIT=YES' target='blank'>DRUKUJ_ZLECENIE</a>";
		if ($_SESSION['CURRENT_MENU'] == 'A_PROBLEM') echo " | </font>" ;
	} else {
		CREATE_MENUFUNC_INIT_2('A_PROBLEM', 'A_PROBLEM', 'ADD', 'DODAJ PROBLEM');
	} //EOF if(strlen($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][A_PROBLEM])>0)

	// run action
	if (($_SESSION['CURRENT_MENU'] == 'A_PROBLEM') && (!($ARG1=='ORDERER'))) {
		//print_r($_SESSION);
		echo "<form action='' method='POST'>
		<input type='hidden' name='FUNCTION_INIT' value='UPDATEDB'><table cellspacing=0 cellpadding=4 border=1>
		<tr><td colspan='2'><b>MENU ZGLASZANIA / USUWANIA PROBLEMOW</b></td></tr>";
		if ($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM'] == 'UNVERIFIED') {
			echo "<tr><td>Rodzaj Problemu / Problem Level</td><td>"; 
			GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM'], $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['A_PROBLEM'], 'A_PROBLEM');
			echo "(obecnie " . $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM'] . ")</td></tr>";
			//	$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][A_PROBLEM] = "";
		}
		else if (strlen($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM']) > 0) {
			echo "<tr><td>Rodzaj Problemu / Problem Level</td><td>";
			echo "<input type='hidden' name='A_PROBLEM' value=''>";
			//	GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][A_PROBLEM],$_SESSION[$thiss->DETECT_TABLE_COLUMN][TYPE][A_PROBLEM],A_PROBLEM);
			echo "Problem usuwany (obecnie " . $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM'] . ")</td></tr>";
		}
		else {
			echo "<tr><td>Rodzaj Problemu / Problem Level</td><td>";
			GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM'], $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['A_PROBLEM'], 'A_PROBLEM');
			echo "(obecnie " . $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM'] . ")</td></tr>";
		}
		echo "<tr><td><br>Opis Problemu/Problem Description:</td><td>" ;
		GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM_DESC'], $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['A_PROBLEM_DESC'], 'A_PROBLEM_DESC');
		echo "</td></tr>";
		if ((strlen($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM']) > 0) && (!($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM'] == 'UNVERIFIED')) ) {
			echo "<tr><td>Typ pracy / T_WORKPOINTS_TYPE</td><td>";
			//	GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][T_WORKPOINTS_TYPE],$_SESSION[$thiss->DETECT_TABLE_COLUMN][TYPE][T_WORKPOINTS_TYPE],T_WORKPOINTS_TYPE);
			T_WORKPOINTS_TYPE_TYPES();
			echo "</td></tr>";
			echo "<tr><td>Data pracy / T_WORKPOINTS_DATE (YYYY-MM-DD)</td><td>";
			GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['TEMPEDITRECORD']['T_WORKPOINTS_DATE'], $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['T_WORKPOINTS_DATE'], 'T_WORKPOINTS_DATE');
			echo "<font size='-2'>"; T_WORKPOINTS_DATE_SELECT(); echo "</font>";
			echo "</td></tr>";
			echo "<tr><td>Wykonawca pracy / T_WORKPOINTS_USER</td><td>";
			//	GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][T_WORKPOINTS_USER],$_SESSION[$thiss->DETECT_TABLE_COLUMN][TYPE][T_WORKPOINTS_USER],T_WORKPOINTS_USER);
			T_WORKPOINTS_USER_SELECT();
			echo "</td></tr>";
			echo "<tr><td>Wartosc pracy / T_WORKPOINTS_VALUE</td><td>";
			GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN]['TEMPEDITRECORD']['T_WORKPOINTS_VALUE'], $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['T_WORKPOINTS_VALUE'], 'T_WORKPOINTS_VALUE');
			echo "<font size='-2'>";
			T_WORKPOINTS_VALUE_TYPES();
			echo "</font>";
			echo "</td></tr>";

			if(substr($thiss->DETECT_TABLE_NAME,0,4)=='SES_' && substr($thiss->DETECT_TABLE_NAME,-2)=='_A') {
				echo "<tr><td>Obciazenie Abonenta / P_ACCOUNT </td><td>";
				echo "<input type=text name='P_ACCOUNT' value='' />";// $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['P_ACCOUNT']
				echo "<font size='-2'>";
				P_ACCOUNT_TYPES();
				echo "</font>";
				echo "</td></tr>";
			}

			echo "<tr><td>Skasowanie danych o  spotkaniach APPOITMENTS / APPOITMENTS var CLEAR</td><td>";
			echo "<input type=checkbox name='DO_APPOITMENT_CLEAR' checked>";
			echo "</td></tr>";
		if(substr($thiss->DETECT_TABLE_NAME,0,4)=='SES_' && substr($thiss->DETECT_TABLE_NAME,-2)=='_A') {
	
				//wykrycie ID_BILLING_USERS jeżeli tabela SES_
				 ZAP_SQL("select ID_BILLING_USERS from SERVICES where ID='".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['ID_SERVICES']."'");
				 list($ID_BILLING_USERS)=mysql_fetch_row($result);
			 if(strlen($ID_BILLING_USERS)<1) {
				  $error.=" Nie znaleziono ID_BILLING_USERS!!! ";
				 }
				 echo "<input type=hidden name='ID_BILLING_USERS' value='$ID_BILLING_USERS'>";
				echo "<tr><td>Uznanie dni niedzialania uslugi zgodnie z datą zgłoszenia i usunięcia usterki (YYYY-MM-DD HH-MM) <input type=\"checkbox\" name=\"DO_DISCONNECT_REPORT\"></td><td>";
				echo "OD:<input type=text size=20 name='DO_DISCONNECT_REPORT_FROM' value=\"".$_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM_DATE']."\">, do dnia wykonania pracy";
				echo "</td></tr>";
			}
		}
		else {//EOF if(strlen($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][A_PROBLEM])>0)
			echo "<tr><td>Data Problemu / A_PROBLEM_DATE</td><td>";
			if( (strlen($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM']) > 1) && (strlen($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM_DATE']) > 1)) {
				$TEMP_A_PROBLEM_DATE = $_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM_DATE'];
			} else {
				$TEMP_A_PROBLEM_DATE = date('Y-m-d-H:i');
			}
			GETFORMITEM($TEMP_A_PROBLEM_DATE, $_SESSION[$thiss->DETECT_TABLE_COLUMN]['TYPE']['A_PROBLEM_DATE'], 'A_PROBLEM_DATE');
			// 2011-11-23: pole nieuzywane, problem z odpisywaniem maila przez klientow
			// @see superedit-UPDATEDB.php
			//if (strlen($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD']['A_PROBLEM']) < 1) {
			//	echo "<tr><td>Przeslanie wiadomosci dla abonenta umozliwiajacej anulowanie problemu</td><td> <input type=checkbox name='A_DB_USER_PROBLEM_REPORT_S_ALIAS_INFO' checked>";
			//}
			echo "</td></tr>";
		}

		echo "<tr><td colspan='2' align='center'><input type='submit' value='      OK      '></td></tr></table></form>";
		CREATE_MENUFUNC_NOTD_INIT($_SESSION['LAST_MENU'], 'POWROT<img src=icon/back.gif border=0 alt=POWROT>');
		echo "<hr>";
	}
}//EOF if($_SESSION[$thiss->DETECT_TABLE_COLUMN][WIEVID]==$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD])
}

	if(isset($error))  echo "ERROR($RESULT,$ERROR ".$error.")";
// print_r($_POST);
// print_r($_SESSION);
// }

} //EOF func A_PROBLEM
