<?php
define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');

/* 載入語言文件 */
//require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/news.php');

/*------------------------------------------------------ */
//-- act 操作项的初始化
/*------------------------------------------------------ */
if (empty($_REQUEST['act']))
{
    $_REQUEST['act'] = 'view';
}

/*------------------------------------------------------ */
//-- PROCESSOR
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'list')
{
		assign_template();
//		assign_dynamic('room');
        $sql = 'SELECT * ' .
               ' FROM ' . $GLOBALS['ecs']->table('hs_room') .
               ' WHERE enable=1 and hs_id= '.$site_id.' order by sort_order asc';

        $rooms = $GLOBALS['db']->getAll($sql);
		$site_name=$GLOBALS['db']->getOne("SELECT cname FROM ".$GLOBALS['ecs']->table('hs_web')." WHERE hs_id=".$site_id);
		$smarty->assign('title',$site_name."-客房列表");
		$smarty->assign('rooms',$rooms);

		$smarty->display('room.html');
}
/*------------------------------------------------------ */
//-- 拍卖商品 --> 出价
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'view')
{
		assign_template();
//		assign_dynamic('room');
        $sql = 'SELECT * ' .
               ' FROM ' . $GLOBALS['ecs']->table('hs_room') .
               ' WHERE id= '.$_REQUEST['id'].
               ' LIMIT 1';
        $room = $GLOBALS['db']->getRow($sql);
		$smarty->assign('room',$room);
        $sql = 'SELECT * ' .
               ' FROM ' . $GLOBALS['ecs']->table('rm_gallery') .
               ' WHERE rm_id= '.$_REQUEST['id'].
               ' Order by img_desc ';
        $rm_gallery = $GLOBALS['db']->getAll($sql);
		$smarty->assign('rm_gallery_list',$rm_gallery);
		$site_name=$GLOBALS['db']->getOne("SELECT cname FROM ".$GLOBALS['ecs']->table('hs_web')." WHERE hs_id=".$site_id);
		$smarty->assign('title',$site_name."-客房介紹-".$room['name']);

		$smarty->display('in_room.html');
}