<%  @calendar_select_interval = 2    %>
	<%	
		$select_id='oper'
		$select_name='операции'	
		$search_command='SensorOperationsSort'
		@pre_part="<div id=\"oper_perf_summ_container\">
				<div class=\"oper_perf_info_block\">
					<img class=\"oper_perf_summ_image\" src=\"/assets/normal.png\" >
					<div id=\"oper_perf_sum_norm\" class=\"oper_perf_summ_text\"><b></b> 0</div>
				</div>
				<div class=\"oper_perf_info_block\">
					<img class=\"oper_perf_summ_image\" src=\"/assets/warning.png\" >
					<div id=\"oper_perf_sum_warn\" class=\"oper_perf_summ_text\"><b></b> 0</div>
				</div>
				<div class=\"oper_perf_info_block\">
					<img class=\"oper_perf_summ_image\" src=\"/assets/error.png\" >
					<div id=\"oper_perf_sum_err\" class=\"oper_perf_summ_text\"\"><b></b> 0</div>
				</div>
				<div class=\"oper_perf_info_block\" style=\"width:210px\">
					<div id=\"oper_perf_uniqe_oper\" class=\"oper_perf_summ_text\" style=\"left:10px\">#{t(:unique_opers)}<b>:</b> 0</div>
				</div>
				<div class=\"oper_perf_info_block\" style=\"width:200px\">
					<div id=\"oper_perf_all_oper\" class=\"oper_perf_summ_text\" style=\"left:10px\">#{t(:all_opers)}<b>:</b> 0</div>
				</div>
				<div class=\"oper_perf_search_field\">
				"
		@post_part='</div></div>'
		@container="#{@pre_part}#{render partial: "shared/search_list", locals: {
			select_id:'oper',
			select_name:t(:oper_search),
			search_command:'operation_sort',
			drop_direction:'up',
			delete_function:0
		}}#{@post_part}"
	%>
	<%
		@gt_structure=[]
			
			@gt_structure.push({:onclick => "", :row_name => t(:status), :value => "'+build_image_kpi(data.data[i].status,data.data[i].kpi)+'", :width => "width:100px", :filter => 'status' })
			@gt_structure.push({:onclick => "", :row_name => t(:type), :value => "'+data.data[i].type_name+'", :width => "width:80px", :filter => 'type_name' })
			@gt_structure.push({:onclick => "", :row_name => '', :value => "'+oper_system_source(data.data[i])+'", :width => "width:60px", :filter => 'short_name' })
			@gt_structure.push({:onclick => "", :row_name => t(:oper), :value => "'+data.data[i].name+'", :width => "", :filter => 'name' })
			@gt_structure.push({:onclick => "", :row_name => t(:count), :value => 
								"'+oper_perf_compare_elements(data.data[i].count,data.data[i].count_avg,0)+'", 
								:width => "width:120px", :filter => 'count' })
			@gt_structure.push({:onclick => "", :row_name => t(:avg_time), :value =>
								"'+oper_perf_compare_elements(data.data[i].duration,data.data[i].duration_avg,1)+'", 
							  :width => "width:180px", :filter => 'duration' })
			@gt_structure.push({:onclick => "", :row_name => t(:user_time), :value => 
							"'+oper_perf_compare_elements(data.data[i].user_time,data.data[i].user_time_avg,1)+'", 
							 :width => "width:150px", :filter => 'user_time' })
			@gt_structure.push({:onclick => "", :row_name => t(:sys_time), :value => 
							"'+oper_perf_compare_elements(data.data[i].sys_time,data.data[i].sys_time_avg,1)+'", 
							 :width => "width:150px", :filter => 'sys_time' })
			@gt_structure.push({:onclick => "", :row_name => "", :value => 
				 			"'+link_oper_map(data.data[i].operation_id)+link_oper_activity(data.data[i].operation_id)+'", 
				 			:width => "width:160px", :filter => 'none' })				
	%>
	<%= render partial: "shared/table", locals: {
		name:"operation_table",
		header:@gt_structure,
		query:"get_perfomance_data",
		action_after:1,
		time:1,
		add_params:', foid:oper_perf_selected_foid',
		offset:50,
		first_sort:'count;DESC',
		additional_field:@container
	} %>
<script>
oper_select_onchange=1
function oper_select_onchage_execute(){
	if (document.getElementById('oper_select_field').value == 0){
		oper_perf_selected_foid=0
		gt_build_table_operation_table(gt_last_sort_operation_table)
	}
}
var oper_perf_selected_foid = 0
function oper_select_search(foid){
		oper_perf_selected_foid=foid
		gt_last_page_operation_table=1
		gt_build_table_operation_table(gt_last_sort_operation_table)
}

function gt_action_after_build_operation_table(data){
	document.getElementById('oper_perf_sum_norm').innerHTML='<b>'+data.detailed_info.green+'</b>'
	document.getElementById('oper_perf_sum_warn').innerHTML='<b>'+data.detailed_info.yellow+'</b>'
	document.getElementById('oper_perf_sum_err').innerHTML='<b>'+data.detailed_info.red+'</b>'
	document.getElementById('oper_perf_uniqe_oper').innerHTML='<%= t(:unique_opers) %>:<b> '+data.detailed_info.unique+'</b>'
	document.getElementById('oper_perf_all_oper').innerHTML='<%= t(:all_opers) %>:<b> '+data.detailed_info.count+'</b>'
}
function oper_perf_compare_elements(real,norm,type){
	if (real != norm && type == 1){
		image='<div style="left:-17px;width:12px;height:12px;float:left;;position:relative;top:14px;border-radius:6px;background:'+(real < norm ? 'transparent' : '<%= $red %>')+'" ></div>'
		//image=''//'<img src="/assets/status_'+(real < norm ? 'up' : 'down')+'.png" style="width:20px;height:20px;float:left;;position:relative;top:10px">'

	}else{
		image='<div style="left:-17px;width:12px;height:20px;float:left;position:relative;top:10px"></div>'
	}
				result=	image+
							'<div style=";height:40px;line-height:20px;float:left;position:relative;left:-12px">'+
										(type == 1 ? second_to_hour_converter(real) : real)+
							'<br>'+
							 		'<div style="color:<%= $blue %>;font-size:12px">'+
							 			(type == 1 ? second_to_hour_converter(norm) : norm)+
									' <%= t('.norm') %></div>'+
							'</div>'
				return result
}
function oper_perf_open_count_window(foid){
	console.log(foid)
	get_to_page_with_parametr('activity','foid='+foid)
}
function oper_perf_open_map_window(foid){
	console.log(foid)
	get_to_page_with_parametr('map','foid='+foid)
}

function calendar_update(){
	gt_last_page_operation_table=1
	gt_build_table_operation_table(gt_last_sort_operation_table)
}

</script>