<?
require_once('include/global.php');
require_once('include/pager.php');
require_once('include/admin_lib.php');
require_once('sadmin_conf.inc.php');


// set
	$CFG['TITLE'] = '<b>메일서버관리</b> >> <b>공휴일 일정 관리</b>';

// data
	// search
		$q_where = '';
		if ($_GET['s_word'])
		{
			set_q_search($_GET['s_word']);
			$q_where = " AND ( di_subject LIKE '%" . $_GET['s_word'] . "%' OR di_content LIKE '%" . $_GET['s_word'] . "%' ) ";
			$v_s_word = htmlspecialchars_fix(stripslashes($_GET['s_word']));
		}	// if()

		$q_where .= " AND d_no is null and m_no=0";

	// sort
		$CFG['ADMIN_HOLIDAY_LIST_FIELD'] = array(
			'di.di_subject' => '이름',
			'di.di_content' => '구분',
			'di.di_startdate' => '시작일',
			'di.di_enddate' => '종료일',
			'di.di_repeat' => '되풀이',
			'di.di_regdate' => '등록일',
		);
		$order_set = get_order(array_keys($CFG['ADMIN_HOLIDAY_LIST_FIELD']), 'di.di_no DESC, di.di_startdate', $_GET['s_key'], $_GET['s_key2']);
		$order_img = get_order_img(array_keys($CFG['ADMIN_HOLIDAY_LIST_FIELD']), $_GET['s_key'], $_GET['s_key2'], false, 'common_skin');		// array

	// db - pager
		$DEBUG['db_cnt']['start'] = getmicrotime();
		$pager_params['totalItems'] = db_get_one("
					SELECT 
						COUNT(di.di_no) 
					FROM 
						" . $TB['DIARY'] . " di 
					WHERE 
						1=1 
						" . $q_where
		);
		$pager_params['perPage'] = 20;
		$DEBUG['db_cnt']['exec'] += getmicrotime() - $DEBUG['db_cnt']['start'];

		// [2016-01-11] PHP 5버전대에서 Ampersand가 DEPRECATED처리되어 &삭제
		#$pager = &new Pager_Sliding($pager_params);
		// [2016-01-11] Ampersand가 DEPRECATED관련하여 PEAR Pager라이브러리 업그레이드 소스적용
		#$pager = new Pager_Sliding($pager_params);
		$pager = Pager::factory($pager_params);
		$pager_links = $pager->getLinks();
		$pager_limit = get_pager_limit($pager->getCurrentPageID(), $pager_params['perPage']);

	// db - select
		$DEBUG['db_select']['start'] = getmicrotime();
		$sql = "
					SELECT
						*
					FROM
						" . $TB['DIARY'] . " di 
					WHERE
						1=1 
						" . $q_where . "
					ORDER BY
						" . $order_set['query'] . "
					";
		$rows = db_get_rows($sql, $pager_limit['from'], $pager_limit['count'], true);

		$rows_cnt = getarraycount($rows['di_subject']);
		$DEBUG['db_select']['exec'] += getmicrotime() - $DEBUG['db_select']['start'];

		for ($i=0; $i<$rows_cnt; $i++)
		{
			$rows['di_content'][$i] = han_substr($rows['di_content'][$i], 60);
		}	// for()

	// 일정수
		$diary_all_cnt = number_format($pager_params['totalItems']);

// skin view
	nskinset('sadmin', 'sadmin_holiday_list.html');
	include($NSKIN['view_layout']);

require_once('include/global_end.php');
?>