function checkTimetableDetail()
{
	var n_time_table_id = document.getElementById('n_time_table_id').value;
	var dt_input = document.getElementById('dt_input').value;
	var flag_error = true;
	if(n_time_table_id == "")
	{
		$('show_error_n_time_table_id').style.display = 'block';
		flag_error = false;
	}
	else
	{
		$('show_error_n_time_table_id').style.display = 'none';		
	}
	
	if(dt_input == "")
	{
		$('show_error_dt_input').style.display = 'block';
		flag_error = false;
	}
	else
	{
		$('show_error_dt_input').style.display = 'none';		
	}
	return flag_error;
	
}
function selectedTimetableDetail(n_time_table_detail_id, n_speciality_id, s_lesson_name, s_term_name, s_location_name, s_first_name, s_middle_name, s_last_name, n_date, s_start_time, s_end_time, s_user_id, n_location_id)
{
	s_user_id = encodeURIComponent(s_user_id);
	var oForm = opener.document.admin_form;
	
	if(oForm.n_time_table_detail_id)
		oForm.n_time_table_detail_id.value = n_time_table_detail_id;
	else if(oForm.n_time_table_id)
		oForm.n_time_table_id.value = n_time_table_detail_id;

	oForm.n_speciality_id.value = n_speciality_id;
	
	var n_date_format = (n_date==8)?"CN":n_date;

	opener.document.getElementById('div_time_table_detail_info').innerHTML = "Môn: " + s_lesson_name + " - Học kỳ: " + s_term_name + " - Phòng: " + s_location_name + " - Giáo viên: " + s_first_name + " " + s_middle_name + " " + s_last_name + " " + " - Thứ: " + n_date_format + " - Từ: " + s_start_time + "h - Đến: " + s_end_time + "h";
	
	if(opener.document.getElementById('hdd_time_table_info') != null)
		opener.document.getElementById('hdd_time_table_info').value = opener.document.getElementById('div_time_table_detail_info').innerHTML;
	
	if(oForm.hdd_s_user_id != null)
	{
		oForm.hdd_s_user_id.value = s_user_id;
	}
		
	if(oForm.hdd_n_location_id != null)
	{			
		oForm.hdd_n_location_id.value = n_location_id;
	}
		
		
		
	self.close();
	if(oForm.btnEnter)
		oForm.btnEnter.disabled = false;
	
	//oForm.hdd_action.value = "search";

	//oForm.submit();					
	
	//showPointAdmin();
	
    
}
function registerInfo()
{

	var n_time_table_detail_id = document.getElementById('n_time_table_detail_id').value;
	var n_speciality_id = document.getElementById('n_speciality_id').value;
	var hdd_s_user_id = encodeURIComponent(document.getElementById('hdd_s_user_id').value);
	var hdd_n_location_id = document.getElementById('hdd_n_location_id').value;
	var hdd_time_table_info = encodeURIComponent(document.getElementById('hdd_time_table_info').value);
	
	var pars = "&n_time_table_detail_id=" + n_time_table_detail_id + "&hdd_s_user_id=" + hdd_s_user_id + "&n_speciality_id=" + n_speciality_id + "&hdd_n_location_id=" + hdd_n_location_id + "&hdd_time_table_info=" + hdd_time_table_info + "&action=select";

	ShowDivGeneral('index.php?do=admin_time_table_detail_info', pars, 'divID');
	
}

function selectTimetableDetail()
{
	if(document.getElementById('btnEnter') != null)
		document.getElementById('btnEnter').disabled = 'disabled';
	var url = "index.php?do=timetable_list&event=select";
	openChild(url, 'win2');

}

function delAdminReceiptFee()
{
	var n_speciality_id = document.getElementById('n_speciality_id').value;
	var n_lesson_id = document.getElementById('n_lesson_id').value;
	var codition = '&n_speciality_id=' + n_speciality_id + '&n_lesson_id=' + n_lesson_id;
	deleteGeneral('admin_receipt_fee', 'receipt_fee', codition);
}

function updateAttendanceAdmin()
{
	var oForm = document.admin_form;
	var n_speciality_id = document.getElementById('n_speciality_id').value;
	var dt_input = document.getElementById('dt_input').value;
	var n_time_table_id = document.getElementById('n_time_table_id').value;

	var arr_attendance_id = oForm.arr_attendance_id;
	var arr_s_user_id = oForm.arr_s_user_id;
	var chk_dt_input = oForm.chk_dt_input;
	//var arr_dt_update;


	var pars = 'n_speciality_id=' + n_speciality_id + '&dt_input=' + dt_input + '&n_time_table_id=' + n_time_table_id + '&action=update';
	var j = 0;
	var url = "index.php?do=admin_attendance";
	if(arr_attendance_id != null)
	{
		var length = arr_attendance_id.length;

		if(length == null)
		{
			pars += '&attendance_id_' + j + '=' + arr_attendance_id.value;
			
			//arr_dt_update = document.getElementById('arr_dt_update_' + i).value;
			if(chk_dt_input.checked)
				pars += '&chk_dt_input_' + j + '=' + chk_dt_input.value;
			else
				pars += '&chk_dt_input_' + j + '=0';
			
			pars += '&user_id_' + j + '=' + arr_s_user_id.value;
			//pars += '&status_flg_' + j + '=' + arr_n_status_flg.value;
			
			j++;
			pars += '&count=' + j;
			
			ShowDivGeneral(url, pars, 'show_attendance');					
		}
		else
		{
			

			for(var i=0; i<length; i++)
			{
				pars += '&attendance_id_' + j + '=' + arr_attendance_id[i].value;
				
				//arr_dt_update = document.getElementById('arr_dt_update_' + i).value;
				if(chk_dt_input[i].checked)
					pars += '&chk_dt_input_' + j + '=' + chk_dt_input[i].value;	
				else
					pars += '&chk_dt_input_' + j + '=0';	
				pars += '&user_id_' + j + '=' + arr_s_user_id[i].value;
				//pars += '&status_flg_' + j + '=' + arr_n_status_flg[i].value;
				
				j++;
			}
			
			pars += '&count=' + j;

			ShowDivGeneral(url, pars, 'show_attendance');			
		}
	}
	else
		alert('Chưa có dữ liệu');	
}

function showAttendance()
{
	var n_speciality_id = document.getElementById('n_speciality_id').value;
	var dt_input = document.getElementById('dt_input').value;
	var n_time_table_id = document.getElementById('n_time_table_id').value;

	var url = "index.php?do=admin_attendance";	
	var pars = 'n_speciality_id=' + n_speciality_id + '&n_time_table_id=' + n_time_table_id + '&dt_input=' + dt_input + '&action=search&index_paging=1';
	ShowDivGeneral(url, pars, 'show_attendance');
}

