<?php

/**
 * 前台 连锁酒店 模块 Controller
 * ============================================================================
 * ZhunaCMS 住哪网酒店分销联盟程序php版　BY Tmac PHP MVC framework
 * $Author: zhangwentao $  <zwttmac@qq.com>
 * $Id: hotel_map.php 19 2011-11-22 11:00:06Z zhangwentao $
 * http://union.zhuna.cn；
 */
class hotel_mapAction extends Action
{

    private $tmp_model;
    private $common_model;
    private $hotel_left_model;
    private $cityinfo;

    public function _init()
    {
        $this->assign('action', $_GET['TMAC_ACTION']);
        $this->tmp_model = Tmac::model('hotel_map');
        $this->common_model = Tmac::model('common');
        $this->hotel_left_model = Tmac::model('hotelLeft');
        //搜索块默认值
        $sk_array = $Searchinfo = $this->hotel_left_model->setLeftSearch();
        //设置SearchCookies$Searchinfo
        $this->hotel_left_model->getSearchCookies($Searchinfo);
        //取cityinfo
        $this->cityinfo = $this->hotel_left_model->getCityinfo();

        //footer里的相关设置
        $config_footer = $this->common_model->footer();
        $this->assign($config_footer);
        $this->assign('sk_array', $sk_array);
        $this->assign('cityinfo', $this->cityinfo);
    }

    public function index()
    {
        $hotels = !empty($_GET['hotels']) ? $_GET['hotels'] : 0;
        $cityid = !empty($_GET['cityid']) ? (int) $_GET['cityid'] : 0;
        $juli = !empty($_GET['juli']) ? $_GET['juli'] : 0;
        $w = !empty($_GET['w']) ? $_GET['w'] : 720;
        $h = !empty($_GET['h']) ? $_GET['h'] : 340;

        $getitems_map = $this->tmp_model->getitems_map($hotels);

        $jsItem_ary = array();
        if (is_array($getitems_map)) {
            foreach ($getitems_map AS $k => $v) {
                $jsItem_ary[] = "['{$v['hotel_id']}','{$v['HotelName']}','{$GLOBALS['TmacConfig']['config']['picurl']}{$v['picture']}','{$v['MapPoint']}','{$v['Address']}','{$v['Min_price']}','{$v['Min_price']}']";
            }
            $jsItem = implode(',', $jsItem_ary);
        } else {
            $jsItem = "[null,null,null,null,null,null,null]";
        }
        $this->assign('jsItem', $jsItem);
        $this->assign('hotels', $hotels);
        $this->assign('cityid', $cityid);
        $this->assign('juli', $juli);
        $this->assign('w', $w);
        $this->assign('h', $h);
        $this->V('hotel_map');
    }

}