<?
	header("Content-Type: text/html; charset=utf-8");
	
	$g_path = '../../my/';
	
	include $g_path."u_globals.php";
	include $g_path."html/f.php";
	include $g_path."u_spoj_na_bazu.php";
	
	include $g_path."u_headers.php";
	
	$l_const_sljedeci_trigger = 120;
	
	switch($_GET['type']){
		case 1:
			$l_sql = 'update alarm set next_trigger_time = unix_timestamp(now()) + '.$l_const_sljedeci_trigger.', shown = 0, on_hold = 0 where rbr = '.$_GET['rbr'];
			$result = sql_exe($l_sql);
			break;
			
		case 2:
			$result = -1;
			$x = get_item('select on_hold from alarm where rbr = '.$_GET['rbr']);
			if($x == 0){
				$l_sql = 'update alarm set on_hold = 1 where rbr = '.$_GET['rbr'];
				sql_exe($l_sql);
				$result = 1;
			}
			if($x == 1){
				$l_sql = 'update alarm set on_hold = 0, next_trigger_time = unix_timestamp(now()) - 5 where rbr = '.$_GET['rbr'];
				sql_exe($l_sql);
				
				$result = 0;
			}
			
			break;
	}
	
	print $result;
?>
